문제
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