Hi Guys.
Still learning PHP and I have been trying for the last few hours to display thumbnails from a database unsuccessfully. I would like them to be in the format:
image1 image2 image3 image4 image5
image6 image7 image8 image9 etc.
regardless of the number of rows returned.
My sql query to retrieve the thumbs is:
<?php require_once('Connections/connections.php'); ?>
<?php
//query user photo thumbs
$user_id = $_SESSION['UserSession'];
$query_pictures = "SELECT picture_id, picture_thumb_url FROM picture WHERE user_id='$user_id'";
$pictures_result = mysql_query($query_pictures) or die(mysql_error());
$pictures = mysql_fetch_assoc($pictures_result);
$rows_pictures = mysql_num_rows($pictures_result);
?>
The thumbs are stored in a folder called User_Pictures. I have been able to retrieve them for example in the profile.php page as follows:
<?php do { ?>
<table width="460" border="0">
<tr>
<td height="50" width="50"><a href="profile.php">
<img src="User_Pictures/<?php echo $avatar_thumb['picture_thumb_url']; ?>"
height="50" width="50" border="0"/></a></td>
<td width="360" colspan="3" class="overide" id="update_box"><div>
<?php echo $row_wid_updates['update_text']; ?></div></td>
<td width="50"><a href="pictures.php">
<img src="User_Pictures/<?php echo $row_wid_updates['picture_thumb_url']; ?>"
height="50" width="50" border="0"/></a></td>
</tr>
</table>
<?php } while ($row_wid_updates = mysql_fetch_assoc($wid_updates)); ?>
I have tried the following code but have been unsuccessful
<?php
echo "\n<table>";
$i = 5;
while ($pictures = mysql_fetch_assoc($pictures_result))
{
if($i==5) echo "\n\t<tr>";
echo "\n\t\t<td><img src=\"".$pictures['picture_thumb_url']."\" /></td>";
$i--;
if($i==0) {
echo "\n\t<tr>";
$i = 5;
}
}
if($i!=5) echo "\n\t\t<td colspan=\"$i\"></td>\n\t</tr>";
echo "\n</table>";
?>
I would greatly appreciate any help out there.