drisate Posted June 2, 2009 Share Posted June 2, 2009 Hey guys ia m trying to create a code that seperates a database result into pages. The code works greate but i am bloking on the part to show only 9 pages at the time in the page menu. Ex: At page 2 the output would look like this << | < | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | > | >> At page 10 the output would look like this << | < | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | > | >> This is the code i made so fare ... The total number of rows is $artiste_nombre and the total number per page is $nombre_par_page the current page is $_GET I just don't get how to make this working ... $maxPage = ceil($artiste_nombre / $nombre_par_page); for ($page = 1; $page <= $maxPage; $page++) { if ($page == $num_page) { $nav .= '<td class="greytable2" align="center" width="25">'.$page.'</td>'; } else { $nav .= '<td class="greytable2" align="center" width="25"><a href="index.php?mod=page&id='.$_GET[id].'&page='.$page.'">'.$page.'</a></td>'; } } if ($num_page > 1) { $page = $num_page - 1; $prev = '<td class="greytable2" align="center" width="25"><a href="index.php?mod=page&id='.$_GET[id].'&page='.$page.'"><</a></td>'; $first = '<td class="greytable2" align="center" width="25"><a href="index.php?mod=page&id='.$_GET[id].'&page=1"><<</a></td>'; } else { //$prev = ' '; //$first = ' '; } if ($num_page < $maxPage) { $page = $num_page + 1; $next = '<td class="greytable2" align="center" width="25"><a href="index.php?mod=page&id='.$_GET[id].'&page='.$page.'">></a></td>'; $last = '<td class="greytable2" align="center" width="25"><a href="index.php?mod=page&id='.$_GET[id].'&page='.$maxPage.'">>></a></td>'; } else { //$next = ' '; //$last = ' '; } // Navigation print ("$first $prev $nav $next $last"); Quote Link to comment https://forums.phpfreaks.com/topic/160697-little-help-would-be-appreciated/ Share on other sites More sharing options...
taquitosensei Posted June 2, 2009 Share Posted June 2, 2009 It's called pagination and there's a tutorial here on phpfreaks http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment https://forums.phpfreaks.com/topic/160697-little-help-would-be-appreciated/#findComment-848077 Share on other sites More sharing options...
drisate Posted June 2, 2009 Author Share Posted June 2, 2009 Thx bro that got me on the way :-) Quote Link to comment https://forums.phpfreaks.com/topic/160697-little-help-would-be-appreciated/#findComment-848104 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.