Search This Blog

Tuesday, July 26, 2011

Php while loop image gallery

If anyone can help me I would be most grateful, Im curently working on a website at the minute that uses images that have been uploaded to a directory, along with a location reference in a MYSQL database.


I have currently got the page to show the thumbnail version of the image, however I want the user to be able to click on the image, and for the image to appear above the thumbnails, the starting image above the thumbnails would be the first result of the mysql query.


I presume this would require Javascript to succeed, however, I have no idea how to go along with this, the code I have so far is :












$album_id = $_GET['album_id'];
echo "

View Album - $album_id



";

$query = mysql_query("SELECT * FROM album WHERE album_id='$album_id'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$site_id = $row['user_id'];

}

$image_query = mysql_query("SELECT image_id, album_id, timestamp, ext
FROM image
WHERE album_id = '$album_id'
AND site_id = '$site_id' ");

echo "Back to image home";

$nextColumn=1;
echo " ";
echo "

";
while ($row1 = mysql_fetch_assoc($image_query)){
$image_id = $row1['image_id'];
$timestamp = $row1['timestamp'];
$ext = $row1['ext'];
$album_id = $row1['album_id'];
$title = $row1['title'];

$thumbsLocation = "uploads/thumbs";
$thumbsLocation2 = "uploads";
$backS = "/";
$dot = ".";
$image_location = $thumbsLocation.$backS.$album_id.$backS.$image_id.$dot.$ext;
$image_location2 = $thumbsLocation2.$backS.$album_id.$backS.$image_id.$dot.$ext;

$get = mysql_query("SELECT image_id, album_id, timestamp, ext FROM image WHERE album_id = '$album_id' AND site_id = '$site_id' ");
$nr = mysql_num_rows($get); // Get total of Num rows from the database query

$size = "80px";

if($nr < 3)
{
$size = "60px";
}

if($nr > 5)
{
$size = "29px";
}

echo "


";
$nextColumn++;
if($nextColumn>6)
{
echo "
";
$nextColumn=1;
}

}
echo '


';

?>



http://bit.ly/qKHyKG

No comments:

Post a Comment