Reputation: 487
I'm trying to implement pagination for a search result. The following code works perfectly:
echo "<p>" . $data['meta']['total'] . " properties found. (search " . $data['meta']['searchId'] . ")</p>\n";
$pages = $data['meta']['total'] / $count;
$pages = ceil($pages);
echo "<p>" . $pages . "</p>\n";
However, if I add in the following, I get a timeout:
$page = 1;
echo "<p>";
while ($page <= $pages); {
echo $page++ . " ";
}
echo "</p>\n";
No doubt I'm missing something obvious.
Upvotes: 1
Views: 91
Reputation: 59681
Your error is here:
while ($page <= $pages); {
//^ See this empty statement here!
echo $page++ . " ";
}
Your while loop loops trough a empty statement so no statement is going to increment $page
. So your curly brackets are just a normal code block, in order to get your while loop working just remove the semicolon like this:
while ($page <= $pages) {
echo $page++ . " ";
}
Upvotes: 2