Quote:
Originally Posted by borked
why can't you do it in a table? Why does it have to be an <UL>?
From a mysql query, let's say you retrieve 20 results (for nice round numbers for this eg) and you want 4 columns.
Then you know there will be 5 rows.
Code:
for ($i=0; $i<$numRows; $i++) {
echo "<tr>";
for ($k=0; $k<$numCols; $k++) {
$key = ($k * $numRows) + $i;
echo "<td>".$content[$key]."</td>
}
echo "</tr>";
}
The code above will fit your 2x3, 3x4, 3x3, 4x5 anything stuff. It just won't handle things having eg 21 results - you need standard code to add cell padding for that.
Kind of like taking a horse to water, but you can't make it drink ;)
|
it's coming from WP so there's not quite as much room code wise