displaying photos 4 per row

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
michlcamp
Forum Commoner
Posts: 78
Joined: Mon Jul 18, 2005 11:06 pm

displaying photos 4 per row

Post by michlcamp »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I know I've seen this here before but don't know where to look...
I want to run a query with a WHILE loop that outputs photos (from a table) four per row and stops when it has no more associated photos...(I'll use tables or CSS to define position)

Say I have ten photos (all the same size) associated with a particular topic ("trucks" , for instance)

I want my result to display:

Code: Select all

echo "
<tr><td>truckphoto1</td><td> truckphoto2</td><td>truckphoto3</td><td>truckphoto4</td></tr>

"<tr><td>truckphoto5</td><td> truckphoto6</td><td>truckphoto7</td><td>truckphoto8</td></tr>

"<tr><td>truckphoto9</td><td> truckphoto10</td><td></td><td></td></tr>
";
any suggestions?

Code: Select all

$$query="SELECT * FROM 'photos' WHERE type='truck'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
HOW DO I OUTPUT 4 PER ROW?

thanks in advance,
mc


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The first two linked threads from Useful Posts may be of interest.
Post Reply