split a result list from mysql into separate lists based on list length
Posted
by liz
on Stack Overflow
See other posts from Stack Overflow
or by liz
Published on 2010-06-11T20:46:51Z
Indexed on
2010/06/11
20:52 UTC
Read the original article
Hit count: 290
i have a list of returned rows from mysql that i am outputting using php:
echo '<ul class="mylist">';
foreach ($rows as $row)
{
echo '<li><a href="'.$row->url.'" target="_blank">' . $row->title . '</a></li>';
}
echo "</ul>";
works fine, but its a long list and i would like to split it into ul chunks so that i can make columns. maybe like 5 results per ul. instead of one ul...
i tried wrapping in a for statement but then just wound up outputting the results 5 times...oops...
© Stack Overflow or respective owner