首页 > php框架 > 本人原创php通用翻页类,支持上*页和下*页..

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

function fPageCount($TotalResult,$numPerPage,$Page){
    $NaviLength=10 ; //显示数量
    $showMorePageGo_Type_=0; //跳转样式
    $int_showNumberLink_=十;
    $nonLinkColor_="#999999";
    $toF_="<font face=webdings title=首页>9</font>" ;
    $toP10_=" <font face=webdings title=上十页>7</font>";
    $toP1_=" <font face=webdings title=上一页>3</font>";
    $toN1_=" <font face=webdings title=下一页>4</font>";
    $toN10_=" <font face=webdings title=下十页>8</font>";
    $toL_="<font face=webdings title=最后一页>:</font>";
    $page_index = "";

    $tpagecount = ceil($TotalResult/$numPerPage);
$nowCoolPage=ceil($Page/$NaviLength);
    $toPage_ = $_SERVER[QUERY_STRING];
    if ( $toPage_ == ) {
       $toPage_ = "?page=";本人原创php通用翻页类,支持上*页和下*页..
    }else {
       $toPage_ = preg_replace("/&?page=d+/", , $toPage_);
       $toPage_ = "?".$toPage_."&page=";
    }
     
if($nowCoolPage == 1){
        $page_index.="<font color=".$nonLinkColor_." title=首页>".$toF_."</font> ";
        $page_index.="<font color=".$nonLinkColor_." title=上".$int_showNumberLink_."页>".$toP10_."</font> ";
    }else{
        $preRow =  $Page-$NaviLength;
  $page_index.="<a href=".$toPage_."1 title=首页>".$toF_."</a> ";
  $page_index.="<a href=".$toPage_.$preRow." title=上".$int_showNumberLink_."页>".$toP10_."</a> ";
    }
    $upRow   = $Page-1;
    $downRow = $Page+1;
    if ($upRow>0){
       $page_index.="<a href=".$toPage_.$upRow." title=上一页>".$toP1_."</a> ";
    }else{
       $page_index.="<font color=".$nonLinkColor_." title=上一页>".$toP1_."</font> ";
    }
     
for($i=1;$i<=$NaviLength;$i++){
         $nowPage=($nowCoolPage-1)*$NaviLength+$i;
         if($nowPage!=$Page){
             if($nowPage<=$tpagecount){
                 $page_index.="  <a href=".$toPage_.$nowPage.">" .$nowPage. "</a> ";
             }else{
                 break;
             }
         }else{
             if($tpagecount != 1){
                $page_index.="<b>".$nowPage."</b>";
             }
         }
      }
     if ($downRow <= $tpagecount){
         $page_index.="<a href=".$toPage_.$downRow." title=下一页>".$toN1_."</a> ";
     }else{
         $page_index.="<font color=".$nonLinkColor_." title=下一页>".$toN1_."</font> ";
     }
     if($nowCoolPage == $tpagecount){
         $page_index.=" <font color=".$nonLinkColor_." title=下".$int_showNumberLink_."页>".$toN10_."</font> ";
         $page_index.="<font color=".$nonLinkColor_." title=尾页>".$toL_."</font>";
     }else{
         $nextRow = $Page+$NaviLength;
         $theEndRow = $tpagecount;
         $page_index.=" <a href=".$toPage_.$nextRow." title=下".$int_showNumberLink_."页>".$toN10_."</a> ";
         $page_index.="<a href=".$toPage_.$theEndRow." title=尾页>".$toL_."</a>";
     }
    if ($showMorePageGo_Type_ ==1){
      $Show_Page_i = $Page + 1 ;
    if ($Show_Page_i>$tpagecount) $Show_Page_i = 1;
    $page_index.="  跳转<input type=text id=skip value= onkeyup=this.value=this.value.replace(/[^d]+/,) style=width:40px/>  <input type=button value=确定 class=btn onclick=location.href=?page=+$(skip).value+".$toPage_.";/>n";
       }else{
       $page_index.=" 跳转:<select name=select size=1 style=font-size: 12px onchange=php教程?name=javascript教程>javascript:window.location.href=this.options[this.selectedIndex].value>";
     for($i=1;$i<=$tpagecount;$i++){
     if($Page==$i){
        $selected=" selected";
     }else{
        $selected="";
        }
        $page_index.=" <option value=".$toPage_.$i;
        $page_index.=$selected." style=color:#FF0000";
        $page_index.=">第".$i."页</option>";
     }
        $page_index.="</select>";
   }
        $page_index.=$p_.$sp2_."  每页<b>".$numPerPage."</b>个记录,现在是:<b><span class=tx>".$sp2_.$Page."</span>/".$tpagecount."</b>页,共<b><span id=recordcount>".$sp2_.$TotalResult."</span></b>个记录。";
    return $page_index;
}


例子:<?php echo fPageCount($TotalResult,$numPerPage,$page)?>   $TotalResult 代表总数 $numPerPage 每页显示数量 $page 页码


教程地址:http://www.phprm.com/frame/php1005020.html

欢迎转载!但请带上文章地址^^

标签:none

发表留言