View Full Version : How to set table cols and rows

05-24-2007, 12:10 AM
I'm trying to make a table of images that I have stored in a database. When it prints out the images they are in a straight line horizontal or vertical, is there a way I can tell the table how many cols I want and the spill over will start a new row?

Example. I want 3 cols and 3 rows

05-24-2007, 04:47 AM
You can develop an HTML table based on the number of rows and columns you need and that will solve your problem

05-24-2007, 05:14 AM

to output that from a database, simply create a loop.
for ($i=0;$i<3;$i++) ... that will go every three times,
then you can create the rest of it.

So, something like--

echo "<table><tr>\n";
foreach ($images as $image) {
echo "<td><img src=\"$image\" alt=\"image\"></td>";
if ($i&#37;3 == 0) {echo "</tr><tr>"; }
echo "</tr></table>";