Click to See Complete Forum and Search --> : Dynamic Gallery and PopUp Gallery


DemonWulf
12-14-2007, 04:45 AM
So yes, what I am trying to do is have my website be totally dynamic. I want to upload images or text files, and have the website automatically update itself. I am doing this for a gallery page with thumbnails. I want it to pull images from a folder and sort the images by date.

Also, the hard part is that I want these thumbnails to link to a single PHP file that will populate a predetermined page-layout with images and text based upon contents of a folder.

The obstacle I am trying to overcome is having each thumbnail on the main gallery page all know to use the PHP file, but then know to go to a certain folder to load in images.

I don't understand how I would make each link point to the same PHP file, but then have the php file know what thumbnail I clicked.

If someone can help me, that would be a huge help. This is the biggest road block, and I think I can figure the rest of it out.

SyCo
12-14-2007, 05:31 PM
The simplest solution that I can think of is on upload, store image data like name, folder etc in a table stored with an ID to use as a reference.

Attach that id to the thumbnail source so the href/image source could be something like
thumbnail.php
q="select * from thumbsdata";//or however you generate your thumbs
$r=mysql_query($q);

while($row=mysql_fetch_assoc($r){
//format however
echo "<a href="display.php?id=".$row['imageid']."><img src=\"thumbnail".$row['thumb_id'].".jpg\" border=0></a>";
}

and display.php
q="select * from imagedata where id=".$_GET['id'];
$r=mysql_query($q);
$row=mysql_fetch_assoc($r);

echo "<img src=\"".$row['foldername']."/".$row['imagename'].".jpg\">";

You can use functions like glob() or opendir()/isdir() to create a folder browsing interface to upload images to particular folders. Then when you choose to upload, store the folder path and other image data in your database.