我这二天也在做,每页按固定记录数显示应该没有问题,主要是页码参数的传递,我现在用类似"http://1.php?page=2"的方式传递,还可以用$_request来做.

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3093/3093475.xml?temp=.4576685****如果你想深入了解一下分页,就看这个帖.如果只是想达到这个效果,就直接上网上搜分页类吧.大把大把的
      

  2.   


    我刚做了一个不知道好不好
    <?php
    $max_row = 5;//每页显示的最大行数
    $current_page = 0;//显示当前记录的页码
    if (isset($_GET['current_page'])) 
      $current_page = $_GET['current_page'];//要显示的当前页
    $begin_record = $current_page * $max_row;//当前显示开始的记录号
    //数据库的连接
    mysql_select_db($database_connected, $connected);
    $sql = "SELECT * FROM reply LIMIT $begin_record,$max_row";
    $Recordset1 = mysql_query($sql, $connected) or die(mysql_error());//执行sql语句
    $row_Recordset1 = mysql_fetch_array($Recordset1);//返回结果查询
    //计算总的记录数和总的页数
    $sql = "SELECT * FROM reply";
    if (isset($total_row)) 
      $total_row = $_GET['total_row'];//总的记录数
    else 
    {
      $all_Recordset1 = mysql_query($sql);//sql查询结果
      $total_row = mysql_num_rows($all_Recordset1);//总的记录数
    }
    $total_page = ceil($total_row/$max_row)-1;//总的页数
    ?>    <td width="150">&nbsp;总共有<?php echo $total_row ?> 条记录</td>
        <td width="64"><a href="<?php printf("$_SERVER[PHP_SELF]?current_page=%d", 0); ?>">第一页</a></td>
        <td width="64"><a href="<?php printf("$_SERVER[PHP_SELF]?current_page=%d",max(0, $current_page - 1)); ?>">上一页</a></td>
        <td width="69"><a href="<?php printf("$_SERVER[PHP_SELF]?current_page=%d",min($total_page, $current_page + 1)); ?>">下一页</a></td>
        <td width="87"><a href="<?php printf("$_SERVER[PHP_SELF]?current_page=%d",$total_page); ?>">最后一页</a></td>
      </tr>
      

  3.   

    //计算总的记录数和总的页数
    $sql = "SELECT count(*) FROM reply";
      

  4.   

    <form method="get" action="monitor_main.php">
      跳转到 第 <input name="page" type="text" /> 页
      <input type="hidden" name="sort" value="<?php echo $sort ;?>" />
      <input type="submit" value="go" />
    </form>