首页上一页 1 下一页尾页 1 条记录 1/1页
查询结果后的分页点下一页为什么会变成查询所有的数据
发表在PHP图书答疑
2010-01-17
是否精华
是
否
版块置顶:
是
否
<?php
include("conn.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加产品</title>
</head>
<body leftmargin=0 topmargin=10>
<table cellpadding=0 border=1 cellspacing=0 align=center>
<tr>
<td width=100><div align=center>LOgo图片</div></td>
<td width=500><div align=left>产品标题</DIV></TD>
<td width=100><div align=left>操作</DIV></TD>
</tr>
<?php
$kuandu=$_POST[kuandu];
$bianpingbi=$_POST[bianpingbi];
$chicun=$_POST[chicun];
$content=$kuandu.$bianpingbi.$chicun;
$pagesize=10;
$sql=mysql_query("select count(*) as total from jutichanpin where guige='$content'");
$info=mysql_fetch_array($sql);
$total=$info[total];
if($total<=$pagesize)
{
$pagecount=1;
}
if($total%$pagesize!=0)
{
$pagecount=ceil($total/$pagesize);
}
else
$pagecount=intval($total/$pagesize);
if($_GET[page]=="")
{
$page=1;
}
else
{
$page=intval($_GET[page]);
}
$sql1=mysql_query("select * from jutichanpin where guige='$content' order by id desc limit ".($page-1)
*$pagesize.",$pagesize");
$info1=mysql_fetch_array($sql1);
if($info1=="")
{
echo "请先添加产品";
}
else
{
do
{
?>
<tr>
<td width=100 hight=100><div align=center><?php echo $info1[tupian];?></div></td>
<td width=500><div align=left><?php echo $info1[biaoti].$info1[buchong];?></DIV></TD>
<td width=100><div align=left><?php echo $info1[jiage];?></DIV></TD>
<?php
}
while($info1=mysql_fetch_array($sql1))
?>
</tr>
</table>
<table cellpadding=0 border=1 cellspacing=0 align=center>
<tr>
<td width=850><div align=center> 本站共有产品<?php echo $total ;?>件 每页显示<?php echo $pagesize;?>件
共<?php echo $pagecount ;?>件 当前是第<?php echo $page ;?>页 <a href="keywordssp.php?page=1" title="首页">
首页</a>
<a href="keywordssp.php?page=<?php
if($page>1)
echo $page-1;
else
echo 1;
?>">上一页</a>
<a href="keywordssp.php?page=<?php
if($page<$pagecount)
echo $page+1;
else
echo $pagecount;
?>">下一页</a>
<a href="keywordssp.php?'apage=<?php echo $pagecount;?>">尾页</a>
</div></td>
</tr>
</table>
<?php
}
?>
</body>
</html>
刚开始查询的时候显示的总页数是对的,但是点下一页的时候就会出现所有的查询,搞不懂是什么原因
include("conn.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加产品</title>
</head>
<body leftmargin=0 topmargin=10>
<table cellpadding=0 border=1 cellspacing=0 align=center>
<tr>
<td width=100><div align=center>LOgo图片</div></td>
<td width=500><div align=left>产品标题</DIV></TD>
<td width=100><div align=left>操作</DIV></TD>
</tr>
<?php
$kuandu=$_POST[kuandu];
$bianpingbi=$_POST[bianpingbi];
$chicun=$_POST[chicun];
$content=$kuandu.$bianpingbi.$chicun;
$pagesize=10;
$sql=mysql_query("select count(*) as total from jutichanpin where guige='$content'");
$info=mysql_fetch_array($sql);
$total=$info[total];
if($total<=$pagesize)
{
$pagecount=1;
}
if($total%$pagesize!=0)
{
$pagecount=ceil($total/$pagesize);
}
else
$pagecount=intval($total/$pagesize);
if($_GET[page]=="")
{
$page=1;
}
else
{
$page=intval($_GET[page]);
}
$sql1=mysql_query("select * from jutichanpin where guige='$content' order by id desc limit ".($page-1)
*$pagesize.",$pagesize");
$info1=mysql_fetch_array($sql1);
if($info1=="")
{
echo "请先添加产品";
}
else
{
do
{
?>
<tr>
<td width=100 hight=100><div align=center><?php echo $info1[tupian];?></div></td>
<td width=500><div align=left><?php echo $info1[biaoti].$info1[buchong];?></DIV></TD>
<td width=100><div align=left><?php echo $info1[jiage];?></DIV></TD>
<?php
}
while($info1=mysql_fetch_array($sql1))
?>
</tr>
</table>
<table cellpadding=0 border=1 cellspacing=0 align=center>
<tr>
<td width=850><div align=center> 本站共有产品<?php echo $total ;?>件 每页显示<?php echo $pagesize;?>件
共<?php echo $pagecount ;?>件 当前是第<?php echo $page ;?>页 <a href="keywordssp.php?page=1" title="首页">
首页</a>
<a href="keywordssp.php?page=<?php
if($page>1)
echo $page-1;
else
echo 1;
?>">上一页</a>
<a href="keywordssp.php?page=<?php
if($page<$pagecount)
echo $page+1;
else
echo $pagecount;
?>">下一页</a>
<a href="keywordssp.php?'apage=<?php echo $pagecount;?>">尾页</a>
</div></td>
</tr>
</table>
<?php
}
?>
</body>
</html>
刚开始查询的时候显示的总页数是对的,但是点下一页的时候就会出现所有的查询,搞不懂是什么原因