如何使用 PHP 显示 MySQL 数据库中的五行,然后创建一个新行并显示另外五行,等等?
问问题
2223 次
4 回答
1
这样的事情可能会有所帮助:
$result = mysql_query($query);
if($result) {
while($row = mysql_fetch_assoc($result)) {
if(++$i%5==0 && $i>0) {
/* do the extra thing... new line some styles */
}
}
}
于 2009-06-23T02:15:26.183 回答
0
错误..你的意思是:
SELECT * FROM `tablename` WHERE ... LIMIT 5
于 2009-06-23T02:13:11.820 回答
0
$total = 20;//get total number here;
$limit = 5;
for($i = 0;$i< $total/$limit;$i++)
{
$sql = $result = $rows = "";
$start = $limit * $i;
$sql = "select * from m_table order by id desc limit $start,$limit";
$result = mysql_query($query);
while($rows = mysql_fetch_assoc($result))
{
//print the result here;
}
}
您可以每次从 mysql 获取 5 行,而无需一次获取所有行。
于 2009-06-23T02:31:20.677 回答