$sql    = "select * from $table limit($begin, 10)";
$query  = mysql_query($conn, $sql);
while($result = mysql_fetch_array($query)){
    echo $result[0];
     ....
}
你每次调用这个页的时候通过GET方式传递$begin的值就可以了,比如:view.php?begin=10,就是从第10条记录开始取出10条来

解决方案 »

  1.   

    我原来写过一个简单的。给你看看吧 ~~ 不是很完善 ~~ 但基本功能是达到的
    <?
    if(!defined("ROW_COUNT")) define("ROW_COUNT",5);require_once(ROOT.'inc/db.inc');if (!$pnum) $pnum=1;class pagination {
    var $last_n;
    var $action;
    var $conn;
    var $sql;
    var $res;
    var $pnum;
    var $test;
    function pagination($sql){
    global $pnum;
    global $link;
    $this->sql=$sql;
    $this->action=$PHP_SELf;
    $link=new DBOperate();
    $this->conn=$link->Link_ID; $this->query_count();
    }
    function query(){
    global $pnum;
    global $link;
    $this->res=$link->query($this->sql." limit ".(($pnum-1)*ROW_COUNT).",".ROW_COUNT." ");
    $this->test=$this->sql." limit ".(($pnum-1)*ROW_COUNT).",".ROW_COUNT." ";

    }function query_count(){
    global $pnum;
    global $last_num;
    global $link; $res=$link->query($this->sql);
    $num=$link->num_rows();
    $this->last_n=ceil($num/ROW_COUNT);
    $last_num=$this->last_n;
    if ($pnum > $last_num) $this->pnum=$last_num;
    if ($pnum<1) $this->pnum=1;
    }
    function show_nav_first(){
    global $pnum;
    global $last_num;
    $first=($pnum<=1)?'#':"$this->action?pnum=1";
    echo "<a href='$first'>第一页</a>";


    }
    function show_nav_pre(){
    global $pnum;
    global $last_num;
    $pre=($pnum<=1)?'#':"$this->action?pnum=".($pnum-1);
    echo "<a href='$pre'>前一页</a>";}
    function show_nav_next(){
    global $pnum;
    global $last_num;
    $next=($pnum>=$last_num)?'#':"$this->action?pnum=".($pnum+1);
    echo "<a href='$next'>后一页</a>";
    }
    function show_nav_last(){
    global $pnum;
    global $last_num;
    $last=($pnum>=$last_num)?'#':"$this->action?pnum=$last_num";
    echo "<a href='$last'>末一页</a>";}function CurrentPage(){
    global $pnum;
    $this->pnum=$pnum;
    }}
    ?>注:db.inc是把基本的数据库封装的一个类,功能嘛,你看方法名就应该可以知道的。具体的实现大概就是这个意思了,你自己改改再用吧
      

  2.   

    试试我的这个类
    <?php
    class pagecontrol{
    var $allitems;//一共有多少项
    var $nextpage;//标志下一个页面页号
    var $thispage;//标志本页面页号
    var $uppage;//标志上一个页面页号
    var $itemcount;//每个页面有多少
    var $currentpage;//标志本页面
    var $pagecount;//一共有多少页
    var $addtion;//附加的url query
    function pagecontrol($pageindex,$nowpage,$itcount,$add){
    $this->allitems=$pageindex;
    $this->itemcount=$itcount;
    $this->nextpage=$nowpage+1;
    $this->uppage=$nowpage-1;
    $this->currentpage=$nowpage;
    $this->pagecount=ceil($pageindex/$itcount);
    $this->addtion=$add;
    }
    function nextpage(){
    if($this->nextpage<$this->pagecount+1){
    echo "<a href=".$PHP_SELF."?".$this->addtion."nowpage=".$this->nextpage.">下一页</a>";
    }
    else echo "下一页";
    }
    function uppage(){
    if($this->uppage>=1){
    echo "<a href=".$PHP_SELF."?".$this->addtion."nowpage=".$this->uppage.">上一页</a>";
    }
    else echo "上一页"; }
    function pagemenu(){//显示页面目录
    for($i=1;$i<=$this->pagecount;$i++){
    if($i==$this->currentpage){
    echo " ".$i." ";
    }
    else {
    echo " <a href=".$PHP_SELF."?".$this->addtion."nowpage=".$i.">".$i."</a> ";
    }
    }
    }
    }
    ?>
      

  3.   

    有没有不用LIMIT的分页方法呀,,