Forum Moderators: open
So if "community==='sonata hills'..." then query the database and use the sonatahills.jpg image...
Is that what i need to do? store the location of the image in the dbase table, and put the image on my server?
would anyone have a good link on how to accomplish this?
or a tip?
thanks all...
We've always done this programatically, so I have no experience in using a text-based admin for this particular purpose (but I use it for all kinds of other stuff).
Usually I make a directory for each type of image (so in your case maybe you create a "communityimages" folder) then name the files the same as their reference in the database... that way I can actually not use a database field to store the image link at all.
I tend to use auto-incrementing id numbers in most of my tables, so all I need to do is use the id for that record in my database as my image filename when it gets uploaded (usually through an upload manager I write... pretty simple). That way in the code I can just have a variable for my standard image location, append the record id, throw on the extension, and presto... there's my file reference. Saves me a field.
$picdirectory = '/images/widgets/';
$imagefile = $picdirectory.$recordid.'.jpg';
echo '<img src="'.$imagefile.'" />';
That's how I do it, but it's just personal preference.