danthorpe2002 Posted June 16, 2006 Share Posted June 16, 2006 Hi, i have a loop running and i want to stop it. insert a new column in a table and then resume the loop from were it stopped how can i do thiis?? This is the current code<td width="130" align="center"><?phpecho mysql_error();$num = mysql_num_rows($result); $j=5;while ($j < $num) {$title=mysql_result($result, $j, 0);$desc=mysql_result($result, $j, 1);$hasImage=mysql_result($result, $j, 2);?> <p><a href="play.php?game=<?php echo $title;?>" title="Play <?php echo $title;?> Flash Game"/><?php echo $title;?><br /><img src="preview/<?php echo($hasImage > 0? $title : "missing");?>.gif" alt="Play <?php echo $title;?> Flash Game" width="90" height="90" border="0"/></p><?php$j++;}?> <td align="center"><?phpecho mysql_error();$num = mysql_num_rows($result); $j=5;while ($j < $num) {$title=mysql_result($result, $j, 0);$desc=mysql_result($result, $j, 1);$hasImage=mysql_result($result, $j, 2);?> <p><a href="play.php?game=<?php echo $title;?>" title="Play <?php echo $title;?> Flash Game"/><?php echo $title;?><br /><img src="preview/<?php echo($hasImage > 0? $title : "missing");?>.gif" alt="Play <?php echo $title;?> Flash Game" width="90" height="90" border="0"/></p><?php$j++;}?></td></td> Quote Link to comment https://forums.phpfreaks.com/topic/12200-php-loop-troubles/ Share on other sites More sharing options...
joquius Posted June 16, 2006 Share Posted June 16, 2006 where do you want to "stop" it? explain what your actual goal is Quote Link to comment https://forums.phpfreaks.com/topic/12200-php-loop-troubles/#findComment-46482 Share on other sites More sharing options...
danthorpe2002 Posted June 16, 2006 Author Share Posted June 16, 2006 Ok, i just need the loop to run 5 times, then insert a new column and resume the loop but i don''t know how to do this, i have indicated in the code were i need the loop to resume <td width="130" align="center"><?phpecho mysql_error();$num = mysql_num_rows($result); $j=5;while ($j < $num) {$title=mysql_result($result, $j, 0);$desc=mysql_result($result, $j, 1);$hasImage=mysql_result($result, $j, 2);?> <p><a href="play.php?game=<?php echo $title;?>" title="Play <?php echo $title;?> Flash Game"/><?php echo $title;?><br /><img src="preview/<?php echo($hasImage > 0? $title : "missing");?>.gif" alt="Play <?php echo $title;?> Flash Game" width="90" height="90" border="0"/></p><?php$j++;}?> <td align="center">//LOOP SHOULD CONTINUE HERE<?phpecho mysql_error();$num = mysql_num_rows($result); $j=5;while ($j < $num) {$title=mysql_result($result, $j, 0);$desc=mysql_result($result, $j, 1);$hasImage=mysql_result($result, $j, 2);?> <p><a href="play.php?game=<?php echo $title;?>" title="Play <?php echo $title;?> Flash Game"/><?php echo $title;?><br /><img src="preview/<?php echo($hasImage > 0? $title : "missing");?>.gif" alt="Play <?php echo $title;?> Flash Game" width="90" height="90" border="0"/></p><?php$j++;}?></td></td> Quote Link to comment https://forums.phpfreaks.com/topic/12200-php-loop-troubles/#findComment-46484 Share on other sites More sharing options...
joquius Posted June 16, 2006 Share Posted June 16, 2006 change the code to thiis[code]$sql = ""; // your sql here$result = mysql_query ($sql) or die (mysql_error ());$num = 0;while ($data = mysql_fetch_array ($result)){ // loop if ($num == 5) echo "</td><td>"; $num++;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12200-php-loop-troubles/#findComment-46485 Share on other sites More sharing options...
danthorpe2002 Posted June 16, 2006 Author Share Posted June 16, 2006 thanks i appreciate youe helpbut which parts of the code go were?? Quote Link to comment https://forums.phpfreaks.com/topic/12200-php-loop-troubles/#findComment-46489 Share on other sites More sharing options...
danthorpe2002 Posted June 17, 2006 Author Share Posted June 17, 2006 Ok, sorted Quote Link to comment https://forums.phpfreaks.com/topic/12200-php-loop-troubles/#findComment-46627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.