pagination error
Posted: Sun Nov 01, 2009 12:46 am
Hello there,
Please am having problem with this below pagination code
the line generating the error is i have tried all i can but didnt work. kindly help me out.
Please am having problem with this below pagination code
Code: Select all
MySQL's COUNT() function. $result = mysql_query("SELECT COUNT(*) AS total_entries FROM products") or die(mysql_error()); $row = mysql_fetch_row($result); $total_entries = $row[0];
$entries_per_page = 3;
if(isset($_GET['page_number'])) { $page_number = $_GET['page_number']; } else { $page_number = 1; }
$total_pages = ceil($total_entries / $entries_per_page);
$result = mysql_query("SELECT * FROM products LIMIT $offset, $entries_per_page") or die(mysql_error()); while($obj = mysql_fetch_object($result)) { // Display the data however you want here. print <<id - $obj->name - $obj->description<br>
EOD; }
for($i = 1; $i <= $total_pages; $i++) { if($i == $page_number) { // This is the current page. Don't make it a link. print "$i "; } else { // This is not the current page. Make it a link. print " <a href="products.php?page_number=$i">$i</a> "; } }
Code: Select all
EOD; }