我看了好多网上的php分页类,都只是显示下面那段1234,数据库查询,然后将查询的结果显示在页面上的那段到底怎么写的,网上很少。
高手帮忙,谢谢。
有数据库(mysql\data\下面的那个数据库文件),要php分页类,php分页显示类(有些是一起的),要完整的实例。
谢谢。我很急。
分不多,哎,见谅!

解决方案 »

  1.   

    晕死, 要不要连模板都提供好呀, 我手上确实有这样的类, 不过这已经包含整个框架性的东西了, 有点水平的人, 谁还会用单独的PHP文件写这种东西
      

  2.   

    <p> <?php 
     include("conn.php");
     include("class/page.php");
     $sql=mysql_query("select * from newsinfo");
     $total=mysql_num_rows($sql);
     
     $page_size=20;
     $nums=$total;
     $sub_pages=25;
     $page_Current=$_GET["p"];
     $page=0;
     if($_GET["p"])
     {
     $pageval=$_GET["p"];
     $page=($pageval-1)*$page_size;
     }
     
     
     $rs=mysql_query("select * from newsinfo  order by n_id desc limit $page,$page_size");
     while($row=mysql_fetch_array($rs))
     {  
    ?>
                     <li><strong><img src="images/arrow1_hover.gif" width="8" height="7">&nbsp;&nbsp;<a href="domains.php" id=<?php echo $row[n_id]?>><?php echo $row[n_Title]?></a></strong></li>
                    <?php } ?>
                  <br/><br/>
                    <li><?php $subPages=new subPages($page_size,$nums,$page_Current,$sub_pages,"list.php?p=",2)?></li></p>
      

  3.   

    class.php如下:你粘贴即可
    <?php
    class SubPages{
      
       private  $each_disNums;//ÿҳʾĿ
      private  $nums;//Ŀ
      private  $current_page;//ǰѡеҳ
      private  $sub_pages;//ÿʾҳ
      private  $pageNums;//ҳ
      private  $page_array = array();//ҳ
      private  $subPage_link;//ÿҳ
      private  $subPage_type;//ʾҳ
       /*
       __constructSubPagesĹ캯ڴʱԶ.
       @$each_disNums   ÿҳʾĿ
       @nums     Ŀ
       @current_num     ǰѡеҳ
       @sub_pages       ÿʾҳ
       @subPage_link    ÿҳ
       @subPage_type    ʾҳ
      
       @subPage_type=1ʱΪͨҳģʽ
             example   4523¼,ÿҳʾ10,ǰ1/453ҳ [ҳ] [ҳ] [ҳ] [βҳ]
             @subPage_type=2ʱΪҳʽ
             example   ǰ1/453ҳ [ҳ] [ҳ] 1 2 3 4 5 6 7 8 9 10 [ҳ] [βҳ]
       */
      function __construct($each_disNums,$nums,$current_page,$sub_pages,$subPage_link,$subPage_type){
       $this->each_disNums=intval($each_disNums);
       $this->nums=intval($nums);
        if(!$current_page){
        $this->current_page=1;
        }else{
        $this->current_page=intval($current_page);
        }
       $this->sub_pages=intval($sub_pages);
       $this->pageNums=ceil($nums/$each_disNums);
       $this->subPage_link=$subPage_link; 
       $this->show_SubPages($subPage_type); 
       //echo $this->pageNums."--".$this->sub_pages;
      }
      
      
      /*
        __destruct಻ʹõʱãúͷԴ
       */
      function __destruct(){
        unset($each_disNums);
        unset($nums);
        unset($current_page);
        unset($sub_pages);
        unset($pageNums);
        unset($page_array);
        unset($subPage_link);
        unset($subPage_type);
       }
      
      /*
        show_SubPagesڹ캯档жʾʲôӵķҳ  
       */
      function show_SubPages($subPage_type){
        if($subPage_type == 1){
        $this->subPageCss1();
        }elseif ($subPage_type == 2){
        $this->subPageCss2();
        }
       }
      
      
      /*
        ҳʼĺ
       */
      function initArray(){
        for($i=0;$i<$this->sub_pages;$i++){
        $this->page_array[$i]=$i;
        }
        return $this->page_array;
       }
      
      
      /*
        construct_num_PageúʹʾĿ
        ʹ[1][2][3][4][5][6][7][8][9][10]
       */
      function construct_num_Page(){
        if($this->pageNums < $this->sub_pages){
        $current_array=array();
         for($i=0;$i<$this->pageNums;$i++){ 
         $current_array[$i]=$i+1;
         }
        }else{
        $current_array=$this->initArray();
         if($this->current_page <= 3){
          for($i=0;$i<count($current_array);$i++){
          $current_array[$i]=$i+1;
          }
         }elseif ($this->current_page <= $this->pageNums && $this->current_page > $this->pageNums - $this->sub_pages + 1 ){
          for($i=0;$i<count($current_array);$i++){
          $current_array[$i]=($this->pageNums)-($this->sub_pages)+1+$i;
          }
         }else{
          for($i=0;$i<count($current_array);$i++){
          $current_array[$i]=$this->current_page-2+$i;
          }
         }
        }
       
        return $current_array;
       }
      
      /*
       ͨģʽķҳ
       4523¼,ÿҳʾ10,ǰ1/453ҳ [ҳ] [ҳ] [ҳ] [βҳ]
       */
      function subPageCss1(){
       $subPageCss1Str="";
       $subPageCss1Str.="".$this->nums."¼";
       $subPageCss1Str.="ÿҳʾ".$this->each_disNums."";
       $subPageCss1Str.="ǰ".$this->current_page."/".$this->pageNums."ҳ ";
        if($this->current_page > 1){
        $firstPageUrl=$this->subPage_link."1";
        $prewPageUrl=$this->subPage_link.($this->current_page-1);
        $subPageCss1Str.="[<a href='$firstPageUrl'>ҳ</a>] ";
        $subPageCss1Str.="[<a href='$prewPageUrl'>һҳ</a>] ";
        }else {
        $subPageCss1Str.="[ҳ] ";
        $subPageCss1Str.="[һҳ] ";
        }
       
        if($this->current_page < $this->pageNums){
        $lastPageUrl=$this->subPage_link.$this->pageNums;
        $nextPageUrl=$this->subPage_link.($this->current_page+1);
        $subPageCss1Str.=" [<a href='$nextPageUrl'>һҳ</a>] ";
        $subPageCss1Str.="[<a href='$lastPageUrl'>βҳ</a>] ";
        }else {
        $subPageCss1Str.="[һҳ] ";
        $subPageCss1Str.="[βҳ] ";
        }
       
        echo $subPageCss1Str;
       
       }
      
      
      /*
       쾭ģʽķҳ
       ǰ1/453ҳ [ҳ] [ҳ] 1 2 3 4 5 6 7 8 9 10 [ҳ] [βҳ]
       */
      function subPageCss2(){
       $subPageCss2Str="";
       $subPageCss2Str.="ǰ".$this->current_page."/".$this->pageNums."ҳ ";
       
       
        if($this->current_page > 1){
        $firstPageUrl=$this->subPage_link."1";
        $prewPageUrl=$this->subPage_link.($this->current_page-1);
        $subPageCss2Str.="[<a href='$firstPageUrl'>ҳ</a>] ";
        $subPageCss2Str.="[<a href='$prewPageUrl'>һҳ</a>] ";
        }else {
        $subPageCss2Str.="[ҳ] ";
        $subPageCss2Str.="[һҳ] ";
        }
       
       $a=$this->construct_num_Page();
        for($i=0;$i<count($a);$i++){
        $s=$a[$i];
         if($s == $this->current_page ){
         $subPageCss2Str.="[<span style='color:red;font-weight:bold;'>".$s."</span>]";
         }else{
         $url=$this->subPage_link.$s;
         $subPageCss2Str.="[<a href='$url'>".$s."</a>]";
         }
        }
       
        if($this->current_page < $this->pageNums){
        $lastPageUrl=$this->subPage_link.$this->pageNums;
        $nextPageUrl=$this->subPage_link.($this->current_page+1);
        $subPageCss2Str.=" [<a href='$nextPageUrl'>һҳ</a>] ";
        $subPageCss2Str.="[<a href='$lastPageUrl'>βҳ</a>] ";
        }else {
        $subPageCss2Str.="[һҳ] ";
        $subPageCss2Str.="[βҳ] ";
        }
        echo $subPageCss2Str;
       }
    }
    ?>