欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

本人原创php通用翻页类,支持上*页和下*页.._PHP教程

程序员文章站 2022-04-20 21:54:08
...
function fPageCount($TotalResult,$numPerPage,$Page){
$NaviLength='10' ; //显示数量
$showMorePageGo_Type_=0; //跳转样式
$int_showNumberLink_='十';
$nonLinkColor_="#999999";
$toF_="9" ;
$toP10_=" 7";
$toP1_=" 3";
$toN1_=" 4";
$toN10_=" 8";
$toL_=":";
$page_index = "";

$tpagecount = ceil($TotalResult/$numPerPage);
$nowCoolPage=ceil($Page/$NaviLength);
$toPage_ = $_SERVER['QUERY_STRING'];
if ( $toPage_ == '' ) {
$toPage_ = "?page=";本人原创php通用翻页类,支持上*页和下*页.._PHP教程
}else {
$toPage_ = preg_replace("/&?page=d+/", '', $toPage_);
$toPage_ = "?".$toPage_."&page=";
}

if($nowCoolPage == 1){
$page_index.="".$toF_." ";
$page_index.="".$toP10_." ";
}else{
$preRow = $Page-$NaviLength;
$page_index.="".$toF_." ";
$page_index.="".$toP10_." ";
}
$upRow = $Page-1;
$downRow = $Page+1;
if ($upRow>0){
$page_index.="".$toP1_." ";
}else{
$page_index.="".$toP1_." ";
}

for($i=1;$i $nowPage=($nowCoolPage-1)*$NaviLength+$i;
if($nowPage!=$Page){
if($nowPage $page_index.=" " .$nowPage. " ";
}else{
break;
}
}else{
if($tpagecount != 1){
$page_index.="".$nowPage."";
}
}
}
if ($downRow $page_index.="".$toN1_." ";
}else{
$page_index.="".$toN1_." ";
}
if($nowCoolPage == $tpagecount){
$page_index.=" ".$toN10_." ";
$page_index.="".$toL_."";
}else{
$nextRow = $Page+$NaviLength;
$theEndRow = $tpagecount;
$page_index.=" ".$toN10_." ";
$page_index.="".$toL_."";
}
if ($showMorePageGo_Type_ ==1){
$Show_Page_i = $Page + 1 ;
if ($Show_Page_i>$tpagecount) $Show_Page_i = 1;
$page_index.=" 跳转n";
}else{
$page_index.=" 跳转:";
}
$page_index.=$p_.$sp2_." 每页".$numPerPage."个记录,现在是:".$sp2_.$Page."/".$tpagecount."页,共".$sp2_.$TotalResult."个记录。";
return $page_index;
}


例子: $TotalResult 代表总数 $numPerPage 每页显示数量 $page 页码

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444955.htmlTechArticlefunction fPageCount($TotalResult,$numPerPage,$Page){ $NaviLength='10' ; //显示数量 $showMorePageGo_Type_=0; //跳转样式 $int_showNumberLink_='十'; $nonLinkColor_=#999999; $...