peteyb383
03-01-2008, 05:18 AM
Hi,
I am pulling data from an SQL database. The data is file paths for image files on the server, the below code shows how the image tags are assembled. I have no problem assembling the code and showing the pictures, however; if there are more than 4 pictures, the table that the pictures are in expands width-wise ruining my site layout.
<table width="535"><tr>
<?php
//SQL Connection...
$result = mysql_query("SELECT * FROM photos WHERE picteam='Amherst'");
while($row = mysql_fetch_array($result))
{
echo '<td><img src="' . $row['path'] . '" height="83" width="125" /></td>';
}
?>
</tr></table>
As I said, the code works, but only for up to 4 pictures, because a new row for the table is not created. If I tried to add the <tr> tags in the loop, a new row would be created for each picture, which I don't want.
I am simply (or not so simply) looking for a method to automatically create a new row so that there are four pictures per row.
Thank you for your time,
Petey
I am pulling data from an SQL database. The data is file paths for image files on the server, the below code shows how the image tags are assembled. I have no problem assembling the code and showing the pictures, however; if there are more than 4 pictures, the table that the pictures are in expands width-wise ruining my site layout.
<table width="535"><tr>
<?php
//SQL Connection...
$result = mysql_query("SELECT * FROM photos WHERE picteam='Amherst'");
while($row = mysql_fetch_array($result))
{
echo '<td><img src="' . $row['path'] . '" height="83" width="125" /></td>';
}
?>
</tr></table>
As I said, the code works, but only for up to 4 pictures, because a new row for the table is not created. If I tried to add the <tr> tags in the loop, a new row would be created for each picture, which I don't want.
I am simply (or not so simply) looking for a method to automatically create a new row so that there are four pictures per row.
Thank you for your time,
Petey