RynMan Posted March 28, 2010 Share Posted March 28, 2010 Hey guys Can someone please tell me why this is looping forever? $i = 0; //row number $PageCount = 0; //current page number in recordset while ($PageCount<=$NumberPages) { if ($PageCount<$NumberPages) { $FromName = $i; $ToName = $i + 23; echo $surname[$FromName]." to ".$surname[$ToName]."<br>"; $i = $ToName + 1; $PageCount++; } else //PageCount = NumberPagee { $FromName = $i; $ToName = $NumberRows; echo $surname[$FromName]." to ".$surname[$ToName]."<br>"; } } It's basically looping just the latter half of my if statement. Thanks guys Link to comment https://forums.phpfreaks.com/topic/196749-looping-forever/ Share on other sites More sharing options...
zeodragonzord Posted March 28, 2010 Share Posted March 28, 2010 You have a while loop that will always equal to true because $PageCount == $NumberPages (both are 0). The value of $PageCount never got changed because the if-statement never returns true, $PageCount is not less than $NumberPages, therefore that block of code never gets run and nothing will change the $PageCount. Link to comment https://forums.phpfreaks.com/topic/196749-looping-forever/#findComment-1032904 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.