php翻页代码出错
可以运行可以得到总页数下一页什么的都可以就是点了翻页后显示的数据还是本页的没变化请帮看下什么问题$conn=mysql_connect("localhost","post...
可以运行 可以得到总页数 下一页什么的都可以
就是点了翻页后显示的数据还是本页的 没变化 请帮看下什么问题
$conn=mysql_connect("localhost","post","password");
mysql_select_db("boubou",$conn);
mysql_query("set names utf8");
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$result = mysql_query("select * from post1",$conn);
$page_count = 3;
echo $result;
echo 111 ;
$row = mysql_num_rows($result);
$page_num = ceil($row/$page_count);
$offect = ($page-1)*$page_count;
$result2 =mysql_query("select * from post1 order by postID desc limit {$offect}, {$page_count}", $conn);
while($array=mysql_fetch_array($result2))
{这部分是html标记,循环输出数据库内容,省略了不然打不下}
以下是翻页表格的代码:
<tr>
<td colspan="3"><div align = "center">
<div align="right">共<?php echo $page_num;?>页 每页<?php echo $page_count;?>条 当前第<?php echo $page;?>页
<a href = "111.php?page =1">首页</a>
<a href = "111.php?page =<?php if($page == 1){echo $page=1;}else{echo $page-1;}?>"> 上一页 </a>
<a href = "111.php?page =<?php if($page<$page_num){echo $page+1;}else{echo $page_num;}?>"> 下一页 </a>
</div></div></td>
</tr>
</table>
<?php ?> 展开
就是点了翻页后显示的数据还是本页的 没变化 请帮看下什么问题
$conn=mysql_connect("localhost","post","password");
mysql_select_db("boubou",$conn);
mysql_query("set names utf8");
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$result = mysql_query("select * from post1",$conn);
$page_count = 3;
echo $result;
echo 111 ;
$row = mysql_num_rows($result);
$page_num = ceil($row/$page_count);
$offect = ($page-1)*$page_count;
$result2 =mysql_query("select * from post1 order by postID desc limit {$offect}, {$page_count}", $conn);
while($array=mysql_fetch_array($result2))
{这部分是html标记,循环输出数据库内容,省略了不然打不下}
以下是翻页表格的代码:
<tr>
<td colspan="3"><div align = "center">
<div align="right">共<?php echo $page_num;?>页 每页<?php echo $page_count;?>条 当前第<?php echo $page;?>页
<a href = "111.php?page =1">首页</a>
<a href = "111.php?page =<?php if($page == 1){echo $page=1;}else{echo $page-1;}?>"> 上一页 </a>
<a href = "111.php?page =<?php if($page<$page_num){echo $page+1;}else{echo $page_num;}?>"> 下一页 </a>
</div></div></td>
</tr>
</table>
<?php ?> 展开
2014-05-03
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询