关于分页的问题 我这二天也在做,每页按固定记录数显示应该没有问题,主要是页码参数的传递,我现在用类似"http://1.php?page=2"的方式传递,还可以用$_request来做. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://community.csdn.net/Expert/topic/3093/3093475.xml?temp=.4576685****如果你想深入了解一下分页,就看这个帖.如果只是想达到这个效果,就直接上网上搜分页类吧.大把大把的 我刚做了一个不知道好不好<?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"> 总共有<?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> //计算总的记录数和总的页数$sql = "SELECT count(*) FROM reply"; <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> 【转】一位资深程序员感悟--编程老手与高手的误区 关于fsockopen函数连接43端口的问题 怎样实现定时操作! xajx在firefox下中文显示为乱码 curl模拟登陆什么意思? 请教如何将二维数组转为指定格式的一位数组 请各位帮忙解决!! unset函数??? php 中的 unset() 函数是什么意思? php中打印输出echo与嵌入html代码两种的比较 一个新手关于phpmyadmin的问题!非常急~~~~ 关于CheckBox数组下标问题,以及TextBox数组下标相对应,应该解决??
我刚做了一个不知道好不好
<?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"> 总共有<?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>
$sql = "SELECT count(*) FROM reply";
跳转到 第 <input name="page" type="text" /> 页
<input type="hidden" name="sort" value="<?php echo $sort ;?>" />
<input type="submit" value="go" />
</form>