homepage Welcome to WebmasterWorld Guest from 54.205.105.23
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Start a new table row in a loop
matthewamzn

5+ Year Member



 
Msg#: 3748316 posted 11:45 pm on Sep 19, 2008 (gmt 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>

 

Anyango

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3748316 posted 5:22 am on Sep 20, 2008 (gmt 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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved