时间:2021-07-01 10:21:17 帮助过:17人阅读
代码如下:
代码如下:
header("Content-Type:text/html;charset=GB2312");
$pagesize=10;
//echo $_POST['page'];
$result = mysql_query("Select count(DISTINCT hotelname) FROM ".TBL_HOTELS);
$myrow = mysql_fetch_array($result);
$numrows=$myrow[0];
$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 `hotelname` , count( * ) from ".TBL_HOTELS." GROUP BY `hotelname` order by id desc limit $offset,$pagesize");
$num = mysql_num_rows($result);
while ($row = mysql_fetch_array($result,MYSQL_NUM)) {
$hotelname[] = $row[0];
$countpeople[] = $row[1];
}
for($a=0;$a<$num;$a++)
{
//$result=mysql_query("select count(title) from " . TBL_Comments ." where `title`=\"".$title[$a]."\"");
//$row = mysql_fetch_row($result);
echo "
\n"; //rating_bar($title[$a],5); echo " | \n"; $hotelname[$a]\n"; echo " |
\n"; | \n"; echo " 推荐人数:($countpeople[$a]) |\n"; echo "平均分: (".$count."票) | 评论数:()\n"; echo " |
"; echo ""; echo " 第".$page."页/总".$pages."页 | 总".$numrows."条 | "; |
以上就介绍了 php,ajax实现分页,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。