PHP自定义函数:简单的分页功能
程序员文章站
2022-06-07 18:16:06
...
/**
* PHP分页自定义函数 ite5e.com
* @param $pageNum:当前页码
* @param $pageSize:每页数量
* @param $rowCount:记录总数
* @param $navUrl:链接页面URL
*/
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."]条数据";
}
?>
* PHP分页自定义函数 ite5e.com
* @param $pageNum:当前页码
* @param $pageSize:每页数量
* @param $rowCount:记录总数
* @param $navUrl:链接页面URL
*/
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."]条数据";
}
?>
上一篇: session的生命周期是多长
下一篇: JavaScript自执行闭包