I have a database that pulls an image from an image folder
that is not part of the DB. The images are named #principal_ID#.png
where the principal_id in the DB is a unique number. The
corresponding images in the image folder are named after the
individuals unique principal_Id so when the name is selected from a
list trhe correct image is selected.
The code used to do this is as follow:
<cfquery name="profileImage" >
SELECT DISTINCT dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID
FROM (dbo.PPS_SCOS JOIN dbo.PPS_TRANSCRIPTS ON
dbo.PPS_SCOS.SCO_ID = dbo.PPS_TRANSCRIPTS.SCO_ID)
JOIN dbo.PPS_PRINCIPALS ON dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID =
dbo.PPS_PRINCIPALS.PRINCIPAL_ID
WHERE dbo.PPS_PRINCIPALS.NAME LIKE '#start#'
AND dbo.PPS_PRINCIPALS.DISABLED IS NULL
</cfquery>
This works OK where there is an image. There are however a
large number of names in the DB where we have no image and would
like to be able to pull in a defualt image where there is none. The
default image is called NAP.
I need to find a way for CF to pull in the default image
where the principal_id does not have the users correct image.
You can use the fileExists() function, but this is a little
inefficient so if you are on Apache you can use mod_Rewrite to
serve the default image if the named file does not exists!!