php简单分页
时间:2021-07-01 10:21:17
帮助过:13人阅读
无标题文档$c />mysql_select_db("qq",$conn);
mysql_query("set names utf8");
$length=5;
$pagenum=isset($_GET['page'])?$_GET['page']:1;
$totsql="select count(*) from q1";
$totarr=mysql_fetch_row(mysql_query($totsql));
$pagetot=ceil($totarr[0]/$length);
if($pagenum>=$pagetot){
$pagenum=$pagetot;
}
$offset=($pagenum-1)*$length;
$sql="select * from q1 order by id limit {$offset},{$length}";
$ret=mysql_query($sql);
echo "
";
echo "";
while($row=mysql_fetch_assoc($ret)){
echo "";
echo "{$row['id']} | ";
echo "{$row['name']} | ";
echo "{$row['pass']} | ";
echo "
";
}
echo "
";
$prevpage=$pagenum-1;
$nextpage=$pagenum+1;
echo "上|下
";
echo "";
mysql_close($conn);
?>
以上就介绍了php 简单分页,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。