DISCUZ 的这个就不错.我都用它~~function multi($num, $perpage, $curr_page, $mpurl) {
$multipage = '';
if($num > $perpage) {
$page = 5;
$offset = 2; $pages = ceil($num / $perpage);
$from = $curr_page - $offset;
$to = $curr_page + $page - $offset - 1;
if($page > $pages) {
$from = 1;
$to = $pages;
} else {
if($from < 1) {
$to = $curr_page + 1 - $from;
$from = 1;
if(($to - $from) < $page && ($to - $from) < $pages) {
$to = $page;
}
} elseif($to > $pages) {
$from = $curr_page - $pages + $to;
$to = $pages;
if(($to - $from) < $page && ($to - $from) < $pages) {
$from = $pages - $page + 1;
}
}
}
$multipage .= "<a href=\"$mpurl&page=1\">&lt;&lt;</a> &nbsp;";
for($i = $from; $i <= $to; $i++) {
if($i != $curr_page) {
$multipage .= "<a href=\"$mpurl&page=$i\">[$i]</a>&nbsp;";
} else {
$multipage .= '<u><b>['.$i.']</b></u>&nbsp;';
}
}
$multipage .= $pages > $page ? " ... <a href=\"$mpurl&page=$pages\"> [$pages] &gt;&gt;</a>" : " <a href=\"$mpurl&page=$pages\">&gt;&gt;</a>";
}
return $multipage;
}

解决方案 »

  1.   

    <?php
    //PEAR中的Pager文件,自己可以下载
    include_once('Pager/Pager.php');
    $products = getResult($keywords);//将要显示的数据,数组类型
    $params = array(
                'mode'       => 'Jumping',
                'perPage'    => 5,
                'delta'      => 5,
                'itemData'   => $products,
                'linkClass'  => 'pageResults',
                );
    $pager = & Pager::factory($params);
    $page_data = $pager->getPageData();
    $links = $pager->getLinks();
    $selectBox = $pager->getPerPageSelectBox();
    $pageOffset = $pager->getOffsetByPageId();
    for ($i=$pageOffset[0]-1; $i<$pageOffset[1]; $i++) {
      //显示
    }  
    echo "Result Pages: &nbsp;" .$links['all'];
    $display = "Displaying %d to %d (of %d products)";
    printf($display, $pageOffset[0], $pageOffset[1], $pager->numItems());
      

  2.   

    之前很多人贴过。<?
    /* $sql = "select count(*)as count from $tbl";
    $db->query($sql);
    $db->next_record();
    $count = $db->f(count);//记录总数

    $page = new ShowPage;
      $page->PageSize = 20;
    $page->Total = $count;
    $page->LinkAry = array(); //使用array("id"=>$id)这样的数组传递url变量
    $sql = "select * from $tbl order by sortid desc limit  ".$page->OffSet();
    $db->query($sql);
    $showpage = $page->ShowLink();  */
    class ShowPage {
     
    var $PageSize;     //每页显示的记录数

    var $Total;        //记录总数

    var $LinkAry;      //Url参数数组,对于复合条件查询分页显示情况非常好用

    //取得总页数
    function PageCount() {
    $TotalPage = ($this->Total % $this->PageSize == 0) ? floor($this->Total / $this->PageSize) :  floor($this->Total / $this->PageSize)+1;
    return $TotalPage;
    }
    //取得当前页
    function PageNum() {
    $page =  (isset( $_GET['page'])!="") ? $_GET['page'] :  $page = 1; 
    return $page;
    }
    //查询语句定位指针
    function OffSet() {
    if ($this->PageNum() > $this->PageCount()) {
            //$this->PageNum = $this->PageCount();
            $pagemin = max(0,$this->Total - $this->PageSize - 1);
            }else if ($this->PageNum() == 1){
            $pagemin = 0;
            }else {
            $pagemin = min($this->Total - 1,$this->PageSize * ($this->PageNum() - 1));
              }
    return $pagemin . "," . $this->PageSize;
        }
    //定位首页
    function FristPage() {
    $Frist = ($this->PageNum() <= 1) ? "首页  " : "<a href=\"?page=1".$this->Url($this->LinkAry)."\">首页</a> ";
    return $Frist;
    }
    //定位上一页
    function PrePage() {
    $prepage=$this->PageNum() - 1;
    $Previous = ($this->PageNum() >= 2) ? " <a href=\"?page=".$prepage.$this->Url($this->LinkAry)."\">上一页</a> " : "上一页 ";
    return $Previous;
    }
    //定位下一页
    function NextPage() {
    $nextpage = $this->PageNum() + 1;
    $Next = ($this->PageNum() <= $this->PageCount()-1) ? " <a href=\"?page=".$nextpage.$this->Url($this->LinkAry)."\">下一页</a> " : "下一页 ";
    return $Next;
    }
    //定位最后一页
    function LastPage() {
    $Last = ($this->PageNum() >= $this->PageCount()) ? "尾页  " : " <a href=\"?page=".$this->PageCount().$this->Url($this->LinkAry)."\">尾页</a> ";
    return $Last;
    }
    //下拉跳转页面
    function JumpPage() {
    $Jump = " 当前第 <b>".$this->PageNum()."</b> 页  共 <b>".$this->PageCount()."</b> 页 跳到 <select name=page onchange=\"javascript:location=this.options[this.selectedIndex].value;\">";
    for ($i=1; $i<=$this->PageCount(); $i++) {
    if ($i==$this->PageNum())
    $Jump .= "<option value=\"?page=".$i.$this->Url($this->LinkAry)."\" selected>$i</option>";
    else 
    $Jump .="<option value=\"?page=".$i.$this->Url($this->LinkAry)."\">$i</option> ";
    }
        $Jump .= "</select> 页   <b>[".$this->PageSize."条/页]</b>";
    return $Jump;
    }
    //URL参数处理
    function Url($ary) {
    $Linkstr = "";
    if (count($ary) > 0) {
    foreach ($ary as $key => $val) {
    $Linkstr .= "&".$key."=".$val;
    }
    }
    return $Linkstr;
    }
    //生成导航条
    function ShowLink() {
    return $this->FristPage().$this->PrePage().$this->NextPage().$this->LastPage().$this->JumpPage();
    }
     }
      

  3.   

    多的一塌啊
    <html><head><title>PHP分页</title></head><body><?
    $PageSize= 50; //每页显示的记录数//连接数据库$id = mysql_connect($hostname,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");//选择数据库$db = mysql_select_db("infodb",$id) or die("无法连接数据库!");//以Customers表为例,构建查询字符串$query = "select * from ipinfo";//执行查询语句$rresult = mysql_query($query) or die("无法执行SQL:$query");//$page变量标示当前显示的页if(!isset($page)) $page=1;if($page==0) $page=1;//得到当前查询到的纪录数 $nNumRowsif(($nNumRows= mysql_num_rows($rresult))<=0){echo "<p align=center>没有纪录";exit;};//得到最大页码数MaxPage$MaxPage = (int)ceil($nNumRows/$gPageSize);if((int)$page > $MaxPage)$page=$maxPage;?><table align="center" width="80%" border=0> <tr><td><? echo "<font size=2>第
    $page 页,共 $MaxPage 页</font>";?></td><td></td></tr></table><table align="center" width="80%" border="1" cellspacing="0" cellpadding="4" bordercolorlight="#CC9966" bgcolor="#00F2EE" bordercolordark="#FFFFFF" class="LZH"><tr bgcolor="#F7F2ff" style="font-size:14.8px;font-weight:bold"><?//显示表格头for($iCnt = 0; $iCnt < mysql_num_fields($rresult); $iCnt++){echo "<td>".mysql_field_name($rresult,$iCnt)."</td>" ;}?></tr><?//根据偏移量($page - 1)*$gPageSize,运用mysql_data_seek函数得到要显示的页面if( mysql_data_seek($rresult,($page-1)*$gPageSize) ){$i=0;//循环显示当前纪录集for($i;$i<$gPageSize;$i++){echo "<tr style=\"font-size:12px\">";//得到当前纪录,填充到数组$arr;$arr= mysql_fetch_row($rresult);if($arr){//循环显示当前纪录的所有字段值for($nOffSet = 0;$nOffSet < count($arr);$nOffSet++){echo "<td>".$arr[$nOffSet]."</td>";}}echo "</tr>";}}?></table><br><hr size=1 width=80%><div align=center style="font-size:12px"><?//首页和上一页的链接if( $nNumRows>1 && $page>1){$prevPage=$page-1;echo " <a href=$PHP_SELF?page=1>首页</a> ";echo " <a href=$PHP_SELF?page=$prevPage >上一页</a> ";}//下一页和末页的链接if( $page>=1 && $page<$MaxPage){$nextPage= $page+1;echo " <a href=$PHP_SELF?page=$nextPage >下一页</a> ";echo " <a href=$PHP_SELF?page=$MaxPage >末页</a> ";}?></div></body></html>
      

  4.   

    http://blog.csdn.net/kingerq/archive/2004/09/29/120354.aspx
    看我这个吧。
      

  5.   

    网上不要太多,随便找找就一大堆.最好自己写一个.用class