php翻页

<?php
$conn = mysql_connect("localhost","root","") or die("连接数据库失败!");
mysql_select_db("test");
mysql_query("set names ‘utf8‘");

$page = "";
if(@$_GET[‘page‘]){
$page = $_GET[‘page‘];
}else{
$page = 1;
}
$pageSize = 2;
//$sum = ($page-1)*$pageSize;
$parentid = 0;
$sum = ($page-1)*$pageSize;
$sql = "select * from tiezi where pid = 0 limit $sum,$pageSize";

$r = "select * from tiezi where pid = 0";
$r = mysql_query($sql);
$count = count($r);
?>

<a href="zhutie.php?page=<?php echo $page-1 ?>">上一页</a>
<?php
$totalPage = $count % $pageSize == 0 ? intval($count / $pageSize) : intval($count / $pageSize) + 1;
for($i=1;$i<=$totalPage;$i++){
?>
<a href="zhutie.php?page=<?php echo $i ?>"><?php echo $i ?></a>
<?php
}
?>
<a href="zhutie.php?page=<?php if($page >= $totalPage){echo $totalPage;}else{echo $page+1;} ?>">下一页</a>

php翻页,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。