Welcome to WebmasterWorld Guest from 54.156.32.65

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)

Full Member

10+ Year Member

joined:Jan 27, 2005
posts: 229
votes: 0


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 Sept 20, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
posts:697
votes: 0



<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]