Gossamer Forum
Home : Products : DBMan : Discussions :

showing images based on the contents of a field

Quote Reply
showing images based on the contents of a field
hi there. I am designing a gallery site using dbman. If I have a field with the names of pictures stored in it (picture.gif, picture2.gif etc) How do I write html which displayes a picture on a page based on the field contents?
I am pretty new to dbman and have trawled through the forum with no success. I dont want to store the actual picture in the database, just the name.

carl
Quote Reply
Re: [carlstevenson] showing images based on the contents of a field In reply to
So you are just storing the photo name and not the url to the photo? If so, you could setup a variable in your .cfg file for the path to your image directory such as this:

$imgdir = '<A HREF="../images">';

using a relative path (from where you have you db files) to the name of YOUR image directory .

Then where you want to display your photos and assuming your field is called "Photo" you could use:

<IMG SRC= "$imgdir/$rec{'Photo'}" width="$rec{'P_W'}" height="$rec{'P_H'}" ALT="$rec{'Caption'}" BORDER=0 ALIGN=Middle>

Rename "Photo" to match the name of the field as defined for your database.

Notice in the above example I have also defined the height and width of the photos as "P_W" and "P_H" as separate fields (so the pages would load quickly). And also used another field for the ALT tag, which could be the field defined for the name of the image.

Hope this gives you some ideas. There are various thread related to working with images in the FAQ noted below under the section "Images".

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] showing images based on the contents of a field In reply to
That works. Thank you