I have pagination, and I want to reach and limit it to 5 page numbers,
See below:
Examples:
PREVIOUS 1 2 3 4 5 NEXT PREVIOUS 20 21 22 23 ... 39 NEXT PREVIOUS 59 ... 81 82 83 84 NEXT
Only five page numbers that they should display.
What part of the code should I change and change?
I am having problems with a combination.
<?php /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous buttons if ($page > 1) $pagination.= "<a class='buttons' href=\"$targetpage?page=$prev\">previous</a>"; else $pagination.= "<a class='disabled'><buttons disabled>previous</buttons></a>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<a class='current'><buttons style='background-color:
I'm having a problem tracking the limit for displaying the page number.
user5018242
source share