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
https://forums.phpfreaks.com/topic/219410-dynamic-rows/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.