Home > php教程 > php手册 > php数字分页类的代码

php数字分页类的代码

WBOY
Release: 2016-06-13 09:59:59
Original
1225 people have browsed it

下面是一款php数字分页类的代码,己经封装好了的代码,需要的朋友可以参考使用一下。分页的主要原理就是获取当前页面,再判断一页多少条记录相除,得出总记录,就这么简单了。

下面是一款php教程数字分页类的代码,己经封装好了的代码,需要的朋友可以参考使用一下。分页的主要原理就是获取当前页面,再判断一页多少条记录相除,得出总记录,就这么简单了。

function getnavhtml($pagenum,$pagesize,$rowcount,$navurl){
$pagecount = (int)($rowcount/$pagesize); //总页数
if ($rowcount % $pagesize >0){
$pagecount++;
}
if ($pagenum>$pagecount){
$pagenum = 1;
}
$firstnav = "首页 ";
$lastnav = "尾页 ";
$prevnav="";
$nextnav="";
if ($pagenum>1){
$navpagenum = $pagenum-1;
$prevnav = "上一页 ";
}
if ($pagenum1){
$navpagenum = $pagenum+1;
$nextnav = "下一页 ";
}
$amongnav="";

//关键循环

for ($i=1;$i $navpagenum = $pagenum+ $i-3;
if ($navpagenum>0 && $navpagenum $navcss教程 = $navpagenum == $pagenum?" class="hover"":"";
$amongnav.="{$navpagenum} ";
}
}
return $firstnav.$prevnav.$amongnav.$nextnav.$lastnav." ".$pagenum."/".$pagecount." 共有[".$rowcount."]条数据";
}
}

/**
* 获取页码导航html
* @param $pagenum:当前页码
* @param $pagesize:每页数量
* @param $rowcount:记录总数
* @param $navurl:链接页面url
*/

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template