lional Posted November 18, 2007 Share Posted November 18, 2007 Hi All I am trying to create page numbers at the bottom of my categories page. I have got it to work sort of but the last thing that I am trying is to only show a certain number of the pages. if I only want to show 15 pages and there are 15 pages or less then it shows all the pages, but if there is say 21 pages then it shows previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 . . . next, and when the user moves onto the second page it shows previous . . . 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 . . . next I have seen it done on some sights I am not sure how to do it, any help will be appreciated Here is my code if ($num_pages == 1 && $num > 0) { print <<<lkh </table> lkh; } // Make the links to other pages, if necessary. $st1 = ($start - $display); $st2 = (($display * ($i - 1))); $st3 = ($start + $display); if ($num_pages > 1) { // Determine what page the script is on. $current_page = ($start/$display) + 1; print <<<ONE <table border="0" cellspacing="0" cellpadding="0" width="590" height="10"><tr><td align="center" valign="top" border="0" height="15"> ONE; // If it's not the first page, make a Previous button. if ($current_page != 1) { print <<<dept1 <a href="category.php?cat_id=$catid&s=$st1&np=$num_pages" style="text-decoration :none"><font color="#d2aa64" size="1" face="arial">Previous</font></a> dept1; } // Make all the numbered pages. for ($i = 1; $i <= $num_pages; $i++) { if ($i != $current_page) { echo '<a href="category.php?cat_id=' . $catid . '&s='. (($display * ($i - 1))) . '&np=' . $num_pages . '" style="text-decoration :none">' . " " . '<font color="#d2aa64" size="1" face="arial">' . $i . '</font></a>'; } else { echo '<font color="#ffffff" size="1" face="arial">' . $i . ' '; } } //it's not the last page, make a Next button. if ($current_page != $num_pages) { print <<<dept3 <a href="category.php?cat_id=$catid&s=$st3&np=$num_pages" style="text-decoration :none"><font color="#d2aa64" size="1" face="arial">Next</font> </td></tr><td height="20"></td></tr> dept3; }} Thanks Lional Link to comment https://forums.phpfreaks.com/topic/77799-page-numbers/ Share on other sites More sharing options...
rarebit Posted November 18, 2007 Share Posted November 18, 2007 Here's some examples on the subject of 'pagination': http://www.phpfreaks.com/quickcode_cats/33/Pagination.php Link to comment https://forums.phpfreaks.com/topic/77799-page-numbers/#findComment-393843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.