PHP+AJAX分页,该如何解决
时间:2021-07-01 10:21:17
帮助过:2人阅读
PHP+AJAX分页
#header("Content-Type:text/html;charset=GB2312");
$pagesize=10;
//echo $_POST['page'];
$db=mysql_connect("localhost","root",""); //创建数据库连接
mysql_query("set names gbk");
mysql_select_db("pagelist");
$result = mysql_query("select * FROM sheet1",$db);
$myrow = mysql_fetch_array($result);
$numrows=mysql_num_rows($result);
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
if (isset($_POST['page'])){
$page=intval($_POST['page']);
}
else{
//设置为第一页
$page=1;
}
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
//计算记录偏移量
$offset=$pagesize*($page - 1);
//读取指定记录数
//$result=mysql_query("select `id` , count( * ) from ".book." GROUP BY `id` order by id desc limit $offset,$pagesize");
$result=mysql_query("select * from sheet1 limit $offset,$pagesize");
$num = mysql_num_rows($result);
while ($row = mysql_fetch_array($result,$db)) {
$hotelname[] = $row[0];
$name[]=$row[1];
$author[]=$row[2];
$publisher[]=$row[3];
$isbn[]=$row[4];
$type[]=$row[5];
$smallpic[]=$row[6];
//$countpeople[] = $row[1];
}
echo "
\n";
echo "\n";
echo "ID编号 | 名称 | 作者 | 出版社 | ISBN号 | 类型 | 价格 | ";
for($a=0;$a<$num;$a++)
{
echo "\n";
echo "".$hotelname[$a]." | ";
echo "".$name[$a]." | ";
echo "".$author[$a]." | ";
echo "".$publisher[$a]." | ";
echo "".$isbn[$a]." | ";
echo "".$type[$a]." | ";
#echo " | ";
人气教程排行