Jump to content
Larry Ullman's Book Forums

Recommended Posts

I created a script that uses the pagination example in the book, and what is happening is that, I have 8 results, if I set the $display variable at 7. I should get a page number to the second page that has the eighth result. But I don't get that, instead it totally ignores the 8th result. 

I looked at the code and thought the problem might be where it says $pages = ceil($records/$display), because it rounds it off, maybe that's why I lose a result. Any idea what could be causing the problem, it is the main pagination script in the book. Maybe I have an error, but after looking for hours I can't find it.

$q = "SELECT COUNT(i.invention_id), c.category_id FROM inventions AS i INNER JOIN categories AS c USING (category_id) WHERE category_id = $cat";
$r = @mysqli_query ($dbc, $q);
$row = @mysqli_fetch_array ($r, MYSQLI_NUM);
$records = $row[0];
// Calculate the number of pages...
if ($records > $display) { // More than 1 page.
$pages = ceil($records/$display);
} else {
$pages = 1;
}

 

Link to comment
Share on other sites

if I set the $display variable at 7. I should get 7 results with a Page link to the next page with the last result, instead it ignores the 8th result and doesn't give me any page links. Could it be that you have to set the display variable to an even number like 10 for it to work properly. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...