In the development of this paging function is certainly indispensable, today we share a very useful and simple PHP paging function implementation code, the need for friends can refer to.
| The code is as follows |
Copy Code |
/**
* Paging function
*
* Total @param int $count entries
* @param int $perlogs show the number of bars per page
* @param int $page current page number
* @param the address of the string $url page number
*/
function pagination ($count, $perlogs, $page, $url, $anchor = ') {
$pnums = @ceil ($count/$perlogs);
$re = ";
$urlHome = Preg_replace ("|[?") &/][^./?&=]*page[=/-]| "," ", $url);
for ($i = $page-5; $i <= $page +5 && $i <= $pnums; $i + +) {
if ($i > 0) {
if ($i = = $page) {
$re. = " $i ";
} elseif ($i = = 1) {
$re. = "$i";
} else {
$re. = "$i";
}
}
}
if ($page > 6) $re = "«... $re ";
if ($page + 5 < $pnums) $re. = "... »";
if ($pnums <= 1) $re = ';
return $re;
} |
http://www.bkjia.com/PHPjc/631677.html www.bkjia.com true http://www.bkjia.com/PHPjc/631677.html techarticle in the development of this paging function is certainly indispensable, today we share a very useful and simple PHP paging function implementation code, the need for friends can refer to. Code such as ...