Jump to content

Looping forever :(


RynMan

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.