PHP Paging function Backup, date 2011-09-25, fixed a few issues.
(1) When the total number of pages is 0 times the problem of calculation.
(2) When the current page is last, the problem of calculation error.
(3) When the total number of pages is small and the number of floating pages.
View Plain
New Paging function
function Fenye ($fenyeurl, $page, $totalnum, $perpage, $rewrite =0) {
$page = Max ($page, 1);
$totalpage = Ceil ($totalnum/$perpage);
$rangepage = 6;
$startpage = max (1, $page-$rangepage);
$endpage = min ($totalpage, $startpage + $rangepage *2-1);
$startpage = min ($startpage, $endpage-$rangepage * + 1);
if ($startpage < 1) $startpage = 1;
$fileext = $rewrite? '. html ': ';
$html = '
';
$html. = '
- Home
';
$html. = $page > 1? '
- Previous page
':'';
for ($i = $startpage; $i <= $endpage; $i + +) {
$html. = '
- '. $i. '
';
if ($i = = $totalpage) break;
}
$html. = $page < $totalpage? '
- Next page
':'';
$html. = '
- Last
';
$html. = '
';
return $html;
}
Author "Default7"
http://www.bkjia.com/PHPjc/478621.html www.bkjia.com true http://www.bkjia.com/PHPjc/478621.html techarticle PHP Paging function Backup, date 2011-09-25, fixed a few issues. (1) When the total number of pages is 0 times the problem of calculation. (2) When the current page is last, the problem of calculation error. ...