这个需要求么?php+mysql的分页最简单了啊!一条sql语句读出所有列出的条目的数量,另外一条语句通过读取当前页信息就OK了剩下的就和之前不需要分页的情况下一样操作就行啊!有点简单的说不过MSSQL就麻烦的多了……

解决方案 »

  1.   

    效果页面  http://www.robote.cn/?f=guest
    在conf.php中放如下的代码<?/*
       a function used to show seprate pages bar
       @author flashlm   @update 2005-07-21
      */
      function showpage($total,$pagestr,$offset=0,$GuestPagesize=10){
       $pages=ceil($total/$GuestPagesize);  //返回不小于 ($total/$pagesize) 的数
       $this_page_no=ceil($offset/$GuestPagesize)+1;
       $temp.="当前:&nbsp;<font color='Red'>".$this_page_no."</font>/".$pages."页&nbsp;&nbsp;共".$total."条&nbsp;&nbsp;";
       if ($offset!=0){
       $temp.="&nbsp;<a href='".$pagestr."&offset=0'>首页</a>&nbsp;";
      }else 
       $temp.="&nbsp;首页&nbsp;";
      if($offset){
       $preoffset=$offset-$GuestPagesize;
       if($preoffset<0){
        $preoffset=0;
       }
       $temp.="&nbsp;<a href='".$pagestr."&offset=".$preoffset."'>上一页</a>&nbsp;";
      }else
       $temp.="&nbsp;上一页&nbsp;";
      $nextoffset=$offset+$GuestPagesize;
      if(($pages!=0)&&($nextoffset<$total))
      {
       $temp.="&nbsp;<a href='".$pagestr."&offset=".$nextoffset."'>下一页</a>&nbsp;";
      }
      else
       $temp.="&nbsp;下一页&nbsp;";
      $last_offset=($pages-1)*$pagesize;
      if($this_page_no!=$pages){
       $temp.="&nbsp;<a href='".$pagestr."&offset=".$last_offset."'>尾页</a>&nbsp;";
      }
      else
       $temp.="&nbsp;尾页&nbsp;";
      $temp.="<select class='input' name='page' size='1' onchange=\"javascript:window.location='".$pagestr."&offset='+this.options[this.selectedIndex].value;\">";
      for($i=0;$i<$pages;$i++){
       $temp.="<option value=".$i*$GuestPagesize."  >第".($i+1)."页</opton>";
      }
      $temp.="</select>";
      return $temp;
       }?>在要用分页程序的页面中(index.php)写如下代码 <?include('conf.php');
    $total  =  db_getone("select count(*) from luo_guest");
       $offset=$_GET["offset"];
     if(empty($offset)||$offset<0){
      $offset=0;
     }
     if($offset>$total){
      $offset=$offset-$GuestPagesize;
     }
     $pagestr="/?f=guest";
     $pagebar=showpage($total,$pagestr,$offset,$GuestPagesize);?>
      

  2.   

    luomingchu: 我先用用看,谢谢你。
      

  3.   

    $total  =  db_getone("select count(*) from luo_guest");
    db_getone是你自己写的吧?
      

  4.   

    luomingchu 显示具体每页的每个数据阶段是如何组织sql的?(while($row= mysql_fetch_array($result)) 这里。麻烦说明下?
      

  5.   

    $total  =  db_getone("select count(*) from luo_guest");
     这个是我自己写的
    就是查询一下数据库而已
    你也可以用 ?(while($row= mysql_fetch_array($result))代替具体显示每一页的话就是 还有一条sql语句忘记给你写出来了 就是查询然后用偏移量就行了
    select * from tale_name limit $offset,$pagesize