Sorry Titan, forgot to post the actually link to the page for the example (fixed now). Can you post a link (or pm me a link) to the problem page as so I can take a look at it?
Sorry Titan, forgot to post the actually link to the page for the example (fixed now). Can you post a link (or pm me a link) to the problem page as so I can take a look at it?
Ok, so I had a further look at the code and came up with the following.
Notice the part in red that I edited. I have tested it, and it works as it should.Code:<?php include('dbconnect.php'); // If page is set if($_GET['page'] && is_numeric($_GET['page'])) { $page = $_GET['page']; } // Set default page else { $page = 1; } // Max results per page $max = 7; // Current page $cur = (($page * $max) - $max); // Get data $qry = mysql_query("SELECT * FROM `test`"); $total = mysql_num_rows($qry); // count results // Get amount of pages $total_pages = ($total / $max); // Is page # more than one if($page > 1) { $prev = ($page - 1); $prevLink = '<a href="?page='.$prev.'"><<Previous</a>'; } // For each page less than total pages for($i=1;$i<$total_pages+1;$i++) { // If page = current page if($page == $i) { $nav .= ' <b>'.$i.'</b> '; } else { // Echo link to previous page $nav .= ' <a href="?page='.$i.'">'.$i.'</a> '; } } // If page is less than total pages, show next link if($page < $total_pages) { $next = ($page + 1); $nextLink = '<a href="?page='.$next.'">Next>></a>'; } ########## End Pagination Script ########## $info = mysql_query("SELECT * FROM `test` ORDER BY `id` DESC LIMIT $cur, $max"); while($row = mysql_fetch_array($info)) { echo $row['title'].' <br />'; } if ($total_pages > 1) { echo 'Pages: '.$prevLink . $nav . $nextLink; } ?>
Hope this helps.
PS: I also pm'd you the code.
Thanks, its working great now![]()
Thanks DD, you saved me countless times
Bookmarks