Davie33 Posted June 30, 2011 Share Posted June 30, 2011 Hi i was hoping someone help me out to recode my pagination.My pagination for looks like this FIRST PREV ( Page 1 of 2 ) NEXT LAST I would like it to be like this FIRST PREV ( 1 2 3 4 5 ) NEXT LAST This is my code if anyone can help me out thanks. if (isset($_GET['page'])) { $pageno = $_GET['page']; } else { $pageno = 1; } $result = yasDB_select("SELECT count(id) FROM games"); $query_data = $result->fetch_array(MYSQLI_NUM);; $numrows = $query_data[0]; $result->close(); $rows_per_page = 20; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; if ($lastpage < 1) { $lastpage = 1; } if ($pageno < 1) { $pageno = 1; } elseif ($pageno > $lastpage) { $pageno = $lastpage; } $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; <?php if ($pageno == 1) { echo ' FIRST PREV '; } else { echo ' <a href="index.php?act=managegames&page=1">FIRST</a> '; $prevpage = $pageno-1; echo ' <a href="index.php?act=managegames&page=' . $prevpage . '">PREV</a> '; } echo ' ( Page ' . $pageno . ' of ' . $lastpage . ' ) '; if ($pageno == $lastpage) { echo ' NEXT LAST '; } else { $nextpage = $pageno+1; echo ' <a href="index.php?act=managegames&page=' . $nextpage . '">NEXT</a> '; echo ' <a href="index.php?act=managegames&page=' . $lastpage . '">LAST</a> '; } echo '<div style="clear:both;"></div></div>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/240753-help-modify-pagination/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.