Welcome to WebmasterWorld Guest from 54.145.208.64

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Start a new table row in a loop

   
11:45 pm on Sep 19, 2008 (gmt 0)

10+ Year Member



I want to make a table that has three columns. In my query I'm pulling out all the images and placing them each inside a table cell. How can I tell it to start a new row after the third image has been pulled.

<table>
<?php
while ($row = mysql_fetch_array($result)) {
echo "<td><an image></td>";
}
?>
</table>

5:22 am on Sep 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<table>
<?php
$nextColumn=1;
echo "<tr>";
while ($row = mysql_fetch_array($result))
{
echo "<td><an image></td>";
$nextColumn++;
if($nextColumn>3)
{
echo "<tr>";
$nextColumn=1;
}
}
?>
</table>

[edited by: Anyango at 5:24 am (utc) on Sep. 20, 2008]