Jump to content

Dynamic Rows


Lucky2710

Recommended Posts

Im working on a site and particularly the photo gallery section. I want to display 9 images on 3 rows (3 per row).

 

And im stuck. Te only way i can get the images to show up not one on top of the other is by using a table. but how can i tell the table to only put 3 <td>'s then to <br>

 

Heres my code so far...

<?php
$sql_images = mysql_query("SELECT * FROM photos ORDER BY upload_date DESC LIMIT 9");

while($row = mysql_fetch_array($sql_images)){

$photo_id = $row["id"];
$location = $row["location"];

		$display_pics .= '
<td width="125px">
<a href="image.php?id='. $album_id .'" class="black"><img src="images/uploads/thumbs/' . $location . '" /></a> 
</td>';
}
?>

Then to display it ...

    	<table width="top" cellpadding="10" cellspacing="20">
        	<tr>
            	<?php echo $display_pics; ?>
            </tr>
        </table>

 

My goal is to do it as simple as possible!

 

Can anyone help?

 

If you don't think tables are the way to go im open to any suggestions.

 

I've thought about <divs> but then the images show up one on top of the other and not beside each other.

 

By the way all the images are a max of 100px heigh and 100px wide

 

Thanks for any help or suggestions!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.