Home  >  Article  >  Backend Development  >  PHP dynamic paging function, a must-have for PHP development of paging_PHP tutorial

PHP dynamic paging function, a must-have for PHP development of paging_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:22:49732browse

贴代码:

复制代码 代码如下:

/**
* Paging function
*
* @param int $count Total number of entries
* @param int $perlogs Number of items displayed on each page
* @param int $page Current page number
* @param string $url The address of the 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;
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/324603.htmlTechArticle贴代码: 复制代码 代码如下: /** * 分页函数 * * @param int $count 条目总数 * @param int $perlogs 每页显示条数目 * @param int $page 当前页码 * @param st...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn