rashmi_k28 Posted August 9, 2008 Share Posted August 9, 2008 Hi, I have the code where if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'>First</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>Previous</a> "; } // end if echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>Next</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>Last</a> "; } Here when I am in first page I should also display First and Previous with no links and When in last page also I have dispaly Next and Last with no links. How to do it Link to comment https://forums.phpfreaks.com/topic/118898-pagination/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.