View Full Version : "while" loop

04-15-2003, 02:07 AM
There seems to be a problem with a loop in my PHP program.

Please download the file (as I have no clue how to use this board's attachment system - I have problems like that all the time)(and it's way too big to post) at http://ionic-empire.ionic-rebellion.net/dm.zip

The code selects a game out of the database, and then runs certain procedures for each game. It's supposed to loop through the games with the game IDs of 1-3 (in my case). The problem is it's only running games with the IDs of 1 and 3, but not 2. Does there seem to be any problems with my loop?

04-15-2003, 02:18 AM
by the way, your link is wrong....its supposed to be http://ionic-empire.ionic-rebellion.net/downloads/dm.zip


04-15-2003, 02:27 AM
there might be a problem just before the while loop, not so much with the syntax. Try and echo out what the data is in $game1[ ] before the while loop to know that "2" is in there. From the looks of it to me, it should work. If there were to be a problem I would say its not doing game 1 or maybe game 3...but I see no reason for game 2 to have a problem.


04-15-2003, 03:45 AM
The output prints out "1", prints out everything it does, and then prints out (for $game[game_id]) "3"

I changed the end of the loop to

$s_g_a = $s_g_a + 1;
db("select * from se_games where paused = 0 && game_id = $s_g_a");

$game = dbr();
echo $game[game_id];

if $s_g_a is 1, then shouldn't it be 2 and not 3?

04-15-2003, 03:49 AM
Seems the only fix I could think of was

if($s_g_a == 1) {
$s_g_a == 2;
} elseif($s_g_a == 2) {
$s_g_a == 3;

Not very pretty, but hey, if it works, it works :)