gpt4 book ai didi

php对mysql结果进行分页

转载 作者:行者123 更新时间:2023-11-29 14:17:06 25 4
gpt4 key购买 nike

我知道我可能会再问一次,但我尝试了分页上可用的问题,但无法正确理解它们...需要知道对以下查询的结果进行分页的方法:

$query = "SELECT * FROM info WHERE Cat1 = 'novel'";
$result = mysql_query($query);
if (!$result) die ("DAtabase acces faild bc : ". mysql_error());

echo " <ul class=listbkwide2>";

while($data = mysql_fetch_object($result))
{
$id = $data->id;
$name = $data->Bname ;
$continent = $data->Bauthor;

echo " <li class=bkd><a href='details.php?bid=$id'>
<img src='images/sbs/$name.jpg' title='$name' alt=''>
<ul class=showcasetitle> <span> $name </span> </ul>
<p class=authname> By <span> $continent</span></p>
";
}
echo " </ul> ";
ini_set('display_errors', '1');
mysql_close();

最佳答案

您需要维护偏移量,然后向查询添加 LIMIT 子句。

[LIMIT {[offset,] row_count | row_count OFFSET offset}]

参见the doc .

关于php对mysql结果进行分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12468670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com