質問
PHPを使用してMySQLデータベースから5行を表示し、新しい行を作成してさらに5行を表示するにはどうすればいいですか?
他のヒント
次のようなことが役立つ場合があります。
$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 */
}
}
}
Err ..次のような意味です:
SELECT * FROM `tablename` WHERE ... LIMIT 5
$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行をフェッチできます。
所属していません StackOverflow