复制代码 代码如下:
/**
* 获取页码导航HTML
* @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 = "<a href=\"{$navUrl}page=1\">首页</a> ";
$lastNav = "<a href=\"{$navUrl}page={$pageCount}\">尾页</a> ";
$prevNav="";
$nextNav="";
if ($pageNum>1){
$navPageNum = $pageNum-1;
$prevNav = "<a href=\"{$navUrl}page={$navPageNum}\">上一页</a> ";
}
if ($pageNum<$pageCount && $pageCount>1){
$navPageNum = $pageNum+1;
$nextNav = "<a href=\"{$navUrl}page={$navPageNum}\">下一页</a> ";
}
$amongNav="";

//关键循环

for ($i=1;$i<=5;$i++){
$navPageNum = $pageNum+ $i-3;
if ($navPageNum>0 && $navPageNum<=$pageCount){
$navCss = $navPageNum == $pageNum?" class=\"hover\"":"";
$amongNav.="<a href=\"{$navUrl}page={$navPageNum}\" $navCss>{$navPageNum}</a> ";
}
}
return $firstNav.$prevNav.$amongNav.$nextNav.$lastNav." ".$pageNum."/".$pageCount." 共有[".$rowCount."]条数据";
}
}
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!