Possible Duplicate:
Break up PHP Pagination links
I have used a simple paging on my web page and it is working. However, my problem is that when the paging links reach numerous amount like
Page: [1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15] and so on.
I wanted to cut it to five links and then show a button for the next 5 links like:
Page: [1],[2],[3],[4],[5] [Next 5].
When I click the [Next 5]
, It will show [Prev 5] [6],[7],[8],[9],[10] [Next 5] and the current page is at page 6.
(Bold character denotes current page.)
Here is the code to be modified:
$perpage = 10;
if(isset($_GET["pagenum"])) {
$page = intval($_GET["pagenum"]);
} else {
$page = 1;
}
$calc = $perpage * $page;
$start = $calc - $perpage;
$orders_count = 150;
$rowss = $orders_count;
if($rowss) {
$total = $orders_count;
}
$totalPages = ceil($total / $perpage);
if($page <=1 ) {
$feedbacks .= "";
} else {
$j = $page - 1;
$feedbacks .= "<a class='first-page' title='Go to the first page' href='" . $path . "&pagenum=$j'>«</a>";
}
for($i=1; $i <= $totalPages; $i++) {
if($i<>$page) {
$feedbacks .= "<a class='first-page' title='Go to the first page' href='" . $path . "&pagenum=$i'>$i</a>";
} else {
$feedbacks .= "<a class='first-page disabled' title='Go to the first page' href='#'>$i</a>";
}
}
if($page == $totalPages ) {
$feedbacks .= "";
} else {
$j = $page + 1;
$feedbacks .= "<a class='last-page' title='Go to the first page' href='" . $path . "&pagenum=$j'>»</a></span>";
}
$feedbacks .= "</div>";
echo $feedbacks;