Page 1 of 1

help creating thumbnails

Posted: Tue Sep 29, 2009 10:49 am
by php_beginner_83
Hi All

I'm trying to create thumbnails on the fly using the gd library. I'm looping through images stored in a database and create thumbnails from these images. However, I can't get this to work. When I explicity type in the name of the image it works.

This is my code....

Code: Select all

 
$result = mysql_query("SELECT * FROM pictures
INNER JOIN pics_in_albums
ON pictures.ID = pics_in_albums.PicID
INNER JOIN albums
ON pics_in_albums.AlbumID = albums.ID
WHERE albums.ID = 1") or die(mysql_error());
 
$paths = array();
 
$counter = 0;
//fetch tha data from the database
while ($row = mysql_fetch_assoc($result))
{
   
   $currentImage = "images//" . substr(strrchr($row['Path'],92),1);
 
   $counter++;
   
   if ($counter % 3 == 0)
   {
        echo '<a href=#><img src="thumb.php?image=$currentImage alt="" /></a><br/>';
   }
   else
   {
        echo '<a href=#><img src="thumb.php?image=$currentImage" alt="" /></a>';
   
   }
   
}
?>
So when I use this, it works ..

Code: Select all

<img src="thumb.php?image=beach.jpg alt="" />
Thanks

Re: help creating thumbnails

Posted: Tue Sep 29, 2009 2:22 pm
by requinix
Don't put the file name in the URL: put an ID number (and maybe album ID) that you can look up. It's safer.

Re: help creating thumbnails

Posted: Tue Sep 29, 2009 4:51 pm
by cpetercarter
Why are there two slashes after 'images' in line 16? Surely you need only one?