php怎么分页显示mysql数据库中的记录?php分页时提示数据未定义改怎么解决?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php怎么分页显示mysql数据库中的记录?php分页时提示数据未定义改怎么解决?相关的知识,希望对你有一定的参考价值。
<?php
$sql=mysql_query("select count(*) as total from tb_info where type='公寓信息' and checkstate=1");
$info=mysql_fetch_array($sql);
$total=$info['total'];
$page = 0;
$pagesize=4;
if ($total<=$pagesize)
$pagecount=1;
if(($total%$pagesize)!=0)
$pagecount=intval($total/$pagesize)+1;
else
$pagecount=$total/$pagesize;
if(($_GET['page'])=="")//这里是第75行
$page=1;
else
$page=intval($_GET['page']);
$gsql=mysql_query("select * from tb_info where type='电脑信息' and checkstate=1 order by edate desc limit ".($page-1)*$pagesize.",$pagesize");
$ginfo=mysql_fetch_array($gsql);
if($ginfo)
do
?>
错误提示:
Notice: Undefined index: page in D:\xampp\htdocs\Computer\main.php
on line 75
它的意思 是说未找到page的索引,也就是$_GET[\'page\']并没有存在,看一下地址里是否有这个参数.如果有,请保证你是不开启了全局变量的配置.追问
能说具体一点吗???我还是有些不明白,刚学php部在懂??我该这么改呢??
追答提示不是好清楚了吗?要不就是你没传递这个传, 要么就是你的PHP配置里禁止了这个...
参考技术A 除以零除数为0从这里找到问题啊。更多注意的错误消息。美元的PAGESIZE的P大写。您定义的变量小写。 ,每页
区分大小写 参考技术B 去看php100的教程,很详细
PHP+MySQL基本分页显示
1.建立连接
2.设定每页显记录数n
3.查询数据
4.关闭连接
每页n条记录,显示第i页,开始记录数s=?
s = ( $i - 1 ) * n
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
![](https://image.cha138.com/20210516/1ba4024ac3ef4e7280f45f6fd5a693bc.jpg)
以上是关于php怎么分页显示mysql数据库中的记录?php分页时提示数据未定义改怎么解决?的主要内容,如果未能解决你的问题,请参考以下文章