PHP翻页点了没反应 而且不能显示数据
$a="selectcount(*)fromcus";$b=mysql_query($a);$c=mysql_fetch_array($b);$count=$c[0];/...
$a="select count(*) from cus";
$b=mysql_query($a);
$c=mysql_fetch_array($b);
$count=$c[0];
/*分页*/
$pagesize=5;
$page=$_GET['page'];
if(empty($page)||$page<0||$count<$pagesize)
{
$page=1;
}
if($count>$pagesize)
{
if($count%$pagesize)
{
$page=$count/$pagesize;
}
else
{
$page=ceil($count/$pagesize)-1;
}
}
/*显示*/
$a1="select * from cus limit ".$page*$pagesize.",".$pagesize;
$show=mysql_query($a1);
while($rs=mysql_fetch_object($show))
{
echo "<p>姓名:".$rs->cus_name."</p>";
echo "<p>留言:".$rs->cus_said."</p>";
for ($i=0;$i<=100;$i++)
{
echo "*";
}
echo "<br>";
}
if($count<$pagesize)
{
echo "首页 | 尾页";
}
if($count>$pagesize&&$page<(ceil($count/$pagesize)-1)&&$page!=0)
{
echo "<a href=index.php?page=".($page-1).">上一页</a> | <a href=index.php?page=".($page+1).">下一页</a>";
}
if($count>$pagesize&&$page=(ceil($count/$pagesize-1)))
{
echo "<a href=index.php?page=".($page-1).">上一页</a> | 下一页";
}
以上是代码 请高手帮忙解决 展开
$b=mysql_query($a);
$c=mysql_fetch_array($b);
$count=$c[0];
/*分页*/
$pagesize=5;
$page=$_GET['page'];
if(empty($page)||$page<0||$count<$pagesize)
{
$page=1;
}
if($count>$pagesize)
{
if($count%$pagesize)
{
$page=$count/$pagesize;
}
else
{
$page=ceil($count/$pagesize)-1;
}
}
/*显示*/
$a1="select * from cus limit ".$page*$pagesize.",".$pagesize;
$show=mysql_query($a1);
while($rs=mysql_fetch_object($show))
{
echo "<p>姓名:".$rs->cus_name."</p>";
echo "<p>留言:".$rs->cus_said."</p>";
for ($i=0;$i<=100;$i++)
{
echo "*";
}
echo "<br>";
}
if($count<$pagesize)
{
echo "首页 | 尾页";
}
if($count>$pagesize&&$page<(ceil($count/$pagesize)-1)&&$page!=0)
{
echo "<a href=index.php?page=".($page-1).">上一页</a> | <a href=index.php?page=".($page+1).">下一页</a>";
}
if($count>$pagesize&&$page=(ceil($count/$pagesize-1)))
{
echo "<a href=index.php?page=".($page-1).">上一页</a> | 下一页";
}
以上是代码 请高手帮忙解决 展开
2011-12-09
展开全部
$page=$_GET['page'];
//page是传递过来的
if(empty($page)||$page<0||$count<$pagesize)
{
$page=1;
}
if($count>$pagesize)
{
if($count%$pagesize)
{
$page=$count/$pagesize;
}
else
{
$page=ceil($count/$pagesize)-1;
}
}
//上面重新计算的,根据记录数面定,不是传过来的page
/*显示*/
$a1="select * from cus limit ".$page*$pagesize.",".$pagesize;
//page是传递过来的
if(empty($page)||$page<0||$count<$pagesize)
{
$page=1;
}
if($count>$pagesize)
{
if($count%$pagesize)
{
$page=$count/$pagesize;
}
else
{
$page=ceil($count/$pagesize)-1;
}
}
//上面重新计算的,根据记录数面定,不是传过来的page
/*显示*/
$a1="select * from cus limit ".$page*$pagesize.",".$pagesize;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询