php 容易分页
程序员文章站
2023-12-27 15:03:51
...
php 简单分页
无标题文档
$conn=mysql_connect("localhost","root","123");
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 "";
";
$prevpage=$pagenum-1;
$nextpage=$pagenum+1;
echo "
echo " ";
mysql_close($conn);
$conn=mysql_connect("localhost","root","123");
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 "
{$row['id']} | ";{$row['name']} | ";{$row['pass']} | ";
$prevpage=$pagenum-1;
$nextpage=$pagenum+1;
echo "
上|下
";echo "
mysql_close($conn);
?>
相关文章
相关视频