4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Loop
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Kdawg
Senior WebHelper
Senior WebHelper


Joined: 21 Apr 2003
Posts: 153

PostPosted: Sun Apr 27, 2003 6:13 pm (20 years, 12 months ago) Reply with QuoteBack to Top

How would I loop some code to go 30 times?
OfflineView User's ProfileFind all posts by KdawgSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Apr 27, 2003 6:15 pm (20 years, 12 months ago) Reply with QuoteBack to Top

What code? I don't understand how this is database related... Confused Do you mean in PHP?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Kdawg
Senior WebHelper
Senior WebHelper


Joined: 21 Apr 2003
Posts: 153

PostPosted: Sun Apr 27, 2003 6:17 pm (20 years, 12 months ago) Reply with QuoteBack to Top

Oh yeah sry, PHP loop, I want to run some code 30 times and then stop.
OfflineView User's ProfileFind all posts by KdawgSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Apr 27, 2003 6:20 pm (20 years, 12 months ago) Reply with QuoteBack to Top

Code:
$i = 1;
while ($i < 30) {
  code_to_run();
  $i++;
}

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Kdawg
Senior WebHelper
Senior WebHelper


Joined: 21 Apr 2003
Posts: 153

PostPosted: Sun Apr 27, 2003 6:34 pm (20 years, 11 months ago) Reply with QuoteBack to Top

How would I put this code into the loop
Code:
$sql = "INSERT INTO Gruhn_Stats (ab) VALUES (NULL)";
$result = mysql_query($sql)
    or die("Invalid query: " . mysql_error());

$result = mysql_query("SELECT * FROM Robinson_Stats")
    or die("Invalid query: " . mysql_error());
OfflineView User's ProfileFind all posts by KdawgSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Apr 27, 2003 6:36 pm (20 years, 11 months ago) Reply with QuoteBack to Top

Code:
$i = 1;
while ($i < 30) {
$sql = "INSERT INTO Gruhn_Stats (ab) VALUES (NULL)";
$result = mysql_query($sql)
    or die("Invalid query: " . mysql_error());

$result = mysql_query("SELECT * FROM Robinson_Stats")
    or die("Invalid query: " . mysql_error());   
$i++;
}


I guess

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Mon Apr 28, 2003 7:07 pm (20 years, 11 months ago) Reply with QuoteBack to Top

Code:

for ($i = 1; $i < 30, ++$i) {
$sql = "INSERT INTO Gruhn_Stats (ab) VALUES (NULL)";
$result = mysql_query($sql)
    or die("Invalid query: " . mysql_error());

$result = mysql_query("SELECT * FROM Robinson_Stats")
    or die("Invalid query: " . mysql_error());   
}

would be better than a while loop...though I can't see what use the code is either way.

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.282594 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme