Solarpitch Posted December 20, 2006 Share Posted December 20, 2006 Hi,Ok . . the following is my pagination code...[code]if (isset($_GET['pageno'])) { $pageno = $_GET['pageno'];} else { $pageno = 1;}$query = "SELECT count(*) FROM adds WHERE class = 'Drivers' AND validation = 1";$result = mysqli_query($mysql_connect, $query) or die (mysqli_error($mysql_connect));$query_data = mysqli_fetch_row($result);$numrows = $query_data[0];$rows_per_page = 2;$lastpage = ceil($numrows/$rows_per_page);$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;$query = "SELECT * FROM adds WHERE class = 'Drivers' AND validation = 1 ORDER BY '$orderby' $limit";$result = mysqli_query($mysql_connect, $query) or die (mysqli_error($mysql_connect));if ($pageno == 1) { echo " FIRST PREV ";} else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> ";} // ifecho " ( Page $pageno of $lastpage ) ";for($i = 1; $i <= $lastpage; $i++){ if($i == $pageno){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } }if ($pageno == $lastpage) { echo " NEXT LAST ";} else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> ";}[/code]This code produces the following...[code]FIRST PREV ( Page 1 of 5 ) 1 2 3 4 5 NEXT LAST[/code]The problem is when you click on a page, it wont jump to that page. Just stays on page 1. The rest seems to work fine. The ideal way I want it is like..<<Prev 1 2 [3] 4 5 6 7 8... Next>>I want to limit it to showning 8 results like above, instead of if there were 20 pages, it been like..<<Prev 1 2 [3] 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Next>>I appriciate that theres loads of code here, but I would be grateful of some help, cheers. Link to comment https://forums.phpfreaks.com/topic/31398-hey-guys-quick-pagination-question/ Share on other sites More sharing options...
craygo Posted December 20, 2006 Share Posted December 20, 2006 here is your problem[code]echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");[/code]you changed your code to look for pageno so it should be[code]echo("<a href=\"$PHP_SELF?pageno=$i\">$i</a> ");[/code]Ray Link to comment https://forums.phpfreaks.com/topic/31398-hey-guys-quick-pagination-question/#findComment-145368 Share on other sites More sharing options...
Solarpitch Posted December 20, 2006 Author Share Posted December 20, 2006 Thanks a mill Ray, kne it was something simple :) Link to comment https://forums.phpfreaks.com/topic/31398-hey-guys-quick-pagination-question/#findComment-145371 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.