当前位置:Gxlcms > PHP教程 > PHP分页问题,请大神现身!分页代码页书显示正确,但每页显示重复内容。

PHP分页问题,请大神现身!分页代码页书显示正确,但每页显示重复内容。

时间:2021-07-01 10:21:17 帮助过:10人阅读

数据库内共有1287条记录,设置每页显示1000条,每行显示9条。

但结果一页里就把所有记录1~1287都显示了,第二页也是1~1287.
分页数是正确的2页,

哪里出了问题请各位帮忙看下代码,十分感谢!
代码如下:
= $page_count) $page = $page_count; $select_limit = $page_size; $select_from = ($page - 1) * $page_size.','; $pre_page = ($page == 1)? 1 : $page - 1; $next_page= ($page == $page_count)? $page_count : $page + 1 ; $pagenav .= "第 $page/$page_count 页 共 $rows 条记录 "; $pagenav .= "首页 "; $pagenav .= "前一页 "; $pagenav .= "后一页 "; $pagenav .= "末页"; $pagenav.=" 跳到\n"; for($i=1;$i<=$page_count;$i++){ if($i==$page) $pagenav.="\n"; else $pagenav.="\n"; } } $conn = mysql_connect('127.0.0.1:8889', 'root', 'root');mysql_select_db('test3', $conn);$rows = mysql_num_rows(mysql_query("select * from cp")); ///@@这段帮你添加的	$limit_start=($page-1)*1000;	$s = "select * from cp limit $limit_start,1000"; ///@@$sql="select * from cp";$r = mysql_query($s);Page($rows,1000); //$s = "select * from cp limit 0,1000"; //$rst = mysql_query($s); //$row = mysql_fetch_array($rst); ?>= "3"?"#999999":"white";    echo $k%9==1?"":"";?>   ":"";   $k++;  } ?>

$sql="select * from cp limit ".($page-1)*1000.",1000";$r = mysql_query($sql);Page($rows,1000); //$s = "select * from cp limit 0,1000"; //$rst = mysql_query($s); //$row = mysql_fetch_array($rst); 上面三行你都没用到,注释掉$sql修改一下,你下面循环用到的是$r对应的sql语句所以一直是一样的

$sql="select * from cp limit ".($page-1)*1000.",1000";$r = mysql_query($sql);Page($rows,1000); //$s = "select * from cp limit 0,1000"; //$rst = mysql_query($s); //$row = mysql_fetch_array($rst); 上面三行你都没用到,注释掉$sql修改一下,你下面循环用到的是$r对应的sql语句所以一直是一样的



$cnt = ($page-1)*1000;$sql="select * from cp limit $cnt,1000";

= $page_count) $page = $page_count; $select_limit = $page_size; $select_from = ($page - 1) * $page_size.','; $pre_page = ($page == 1)? 1 : $page - 1; $next_page= ($page == $page_count)? $page_count : $page + 1 ; $pagenav .= "第 $page/$page_count 页 共 $rows 条记录 "; $pagenav .= "首页 "; $pagenav .= "前一页 "; $pagenav .= "后一页 "; $pagenav .= "末页"; $pagenav.=" 跳到

忘记密码?

登录