Skip to main content
Inspiring
April 6, 2008
Answered

CFDIRECTORY - filtering images

  • April 6, 2008
  • 2 replies
  • 505 views
I have a personals web site where the database has a field indicating the gender of a member; 1 for male, 2 for female. How can I get a list of all images using cfdirectory of only the men, or only the women? Thanks!
This topic has been closed for replies.
Correct answer Newsgroup_User
obviously, cfdirectory has no idea if your member is M or F or which
image belongs to which member, only your db does...
so QoQ is your friend:
a) get all images with cfdirectory
b) select necessary records from db - you db must have a field for the
image filename which will be compared to the results of cfdirectory query
c) do QoQ to combine the 2 queries and select only images of M or F

sample code to select all images of M members:
<cfdirectory name="dirQuery" ...>
<cfquery name="dbQuery" ...>
SELECT imageid, imagefilename, gender
FROM images
WHERE gender = 'M'
</cfquery>
<cfquery name="qoq" dbtype="query">
SELECT *
FROM dirQuery, dbQuery
WHERE dirQuery.name = dbQuery.imagefilename
</cfquery>

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

2 replies

ssailerAuthor
Inspiring
April 7, 2008
yes, that worked. Thank you!
Newsgroup_UserCorrect answer
Inspiring
April 7, 2008
obviously, cfdirectory has no idea if your member is M or F or which
image belongs to which member, only your db does...
so QoQ is your friend:
a) get all images with cfdirectory
b) select necessary records from db - you db must have a field for the
image filename which will be compared to the results of cfdirectory query
c) do QoQ to combine the 2 queries and select only images of M or F

sample code to select all images of M members:
<cfdirectory name="dirQuery" ...>
<cfquery name="dbQuery" ...>
SELECT imageid, imagefilename, gender
FROM images
WHERE gender = 'M'
</cfquery>
<cfquery name="qoq" dbtype="query">
SELECT *
FROM dirQuery, dbQuery
WHERE dirQuery.name = dbQuery.imagefilename
</cfquery>

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/