时间:2021-07-01 10:21:17 帮助过:19人阅读
结合jquery做ajax分页
//PHP分页实例
//分页尺寸
$page_size=10;
$conn=mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("xinyang");
//计算总行数
$total_records=mysql_num_rows(mysql_query("SELECT id from product"));
//总页数
$total_page=ceil($total_records/$page_size);
$query=mysql_query("select * from product limit 0,$page_size") or die(mysql_error());
?>
$page=$_GET["page"]+0;
$page= $page<=0 ? 1 : $page;
//分页尺寸
$page_size=10;
$conn=mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("xinyang");
$offset=($page-1)*$page_size;
$query=mysql_query("select * from product limit $offset,$page_size") or die(mysql_error());
?>