April 18th, 2000, 10:58 PM
I want to create a photo album of images that are indexed in the database but the actual images reside in another folder. I am able to query the database for things like catalog number, title, etc. But I haven't figured out a way to (when I look at the online PHP documentatiom, I go loopy) get the images from that folder and display them on the results page.
Ideally, I would love to have a search result of thumbnails with links the the larger photos.
Anyway, any assistance would be appreciated.
April 19th, 2000, 07:47 AM
-doc_root (script here)
-images (full size images here, maybe with subdirectories)
-thumbs (thumbnails here)
With seperate directories you could name the thumbnails the same as the full-size image but I would still give it a prefix such as "tn_".
Include in your table the field image_name.
Assuming your query is something like:
$result=mysql_query("select * from table where whatever");
//whatever else you need in here to format the display
// add this line to show the thumb as a link
// to the fullsize image:
print "<a href='../images/".$data[image_name]."'><img src='../thumbs/".$data[image_name]."'</a>";
Above is untested code. I might have made a small error but the logic will work.
April 19th, 2000, 07:51 AM
I find it useful to name my images to the id of the table ie: if record> id=1 name=dog etc
I name the image that refers to dog as 1.gif or .jpg , put the thumbnail size images in directory 'thumbs' and the larger images in the directory 'large' then when I have my query & assuming $Myrow[$x] is the id -
<a href="bigPicPage.php3?pic=<?php echo "Myrow[$x]";?>">
<img src="images/thumbs/<?php echo "Myrow[$x]";?>.gif width=etc">
then the bigPicPage would contain
<img src="images/large/<?php echo "$pic";?>.gif">
you can keep all the images in 1 folder and name them 1.gif , 1a.gif etc but I find keeping 2 dirs keeps things nice and tidy.
If for some reason you have different sized images then you can use the GetImageSize() function to fill in the width/height of your thumbs - although normally thumbs of the same size look best?
hope this helps
April 20th, 2000, 12:51 AM
Thanks a ton! I got rod k's script going.
Got one more piece to the large puzzle I have in front of me =)
I will move onto creating the search function, but first I am going to create pages using PHP and the database and what I just learned. Then, implenting the search function will be easier, I think.
April 21st, 2000, 07:11 PM
Wadez, if you can get a search function to work where it will search the entire description for keywords instead of just the first word in the description, please let me know how you did it
April 21st, 2000, 11:12 PM
OK never mind I figured out my problems.
April 22nd, 2000, 01:51 PM
Ooh, how did you do that CS?