Bob,
Probably a few different approaches you can take here, but if all you want
is a list of the all the e-mail addresses from your query and combine them
into one list, try this (untested):
<cfif getformEmails.recordCount>
<cfset lsCCEmailAddresses = valueList(getFormEmails.cc_email1) >
<cfif listLen(valueList(getFormEmails.cc_email2))>
<cfset lsCCEmailAddresses = lsCCEmailAddresses & "," &
valueList(getFormEmails.cc_email2) >
</cfif>
<cfif listLen(valueList(getFormEmails.cc_email3))>
<cfset lsCCEmailAddresses = lsCCEmailAddresses & "," &
valueList(getFormEmails.cc_email3) >
</cfif>
<cfif listLen(valueList(getFormEmails.cc_email4))>
<cfset lsCCEmailAddresses = lsCCEmailAddresses & "," &
valueList(getFormEmails.cc_email4) >
</cfif>
<cfelse>
<cfset lsEmailAddresses = "">
</cfif>
FYI - You don't need to do a <cfparam> to specify that columns from a query
exist. When you execute a query, even if you don't get any data back, you
still get the column names, so those lines of code are unnecessary.
Dave Phillips
-----Original Message-----
From: Imperial, Bob [mailto:[email protected]]
Sent: Wednesday, October 07, 2009 9:04 AM
To: cf-newbie
Subject: building a list help
Hi folks,
I am trying to get my head around coding a list based on query results and
I'm just not seeing it. I don't know if my approach is wrong and maybe I
should be using the listAppend() function or what. I have a query that grabs
the values from 4 fields that hold email addresses. The result set may or
may not return a value for each so I need to somehow account for those in
building a final list of email addresses that I can drop into the CC field
in emails. Here's roughly what I have thus far:
<cfquery name="getFormEmails" datasource="#dsdata3#">
SELECT * FROM tblrequesttypes
WHERE request_type = '#form.PageTitle#'
</cfquery>
<cfparam name="getFormEmails.cc_email1" default="" />
<cfparam name="getFormEmails.cc_email2" default="" />
<cfparam name="getFormEmails.cc_email3" default="" />
<cfparam name="getFormEmails.cc_email4" default="" />
This is the part that's making mush of my brain and has me stumped. In this
particular instance I get 2 out of 3 email addresses that are in the result
set.
<cfif Len(getFormEmails.cc_email1)>
<cfset CCList = getFormEmails.cc_email1 />
<cfif getFormEmails.cc_email2 NEQ "">
<cfset CCList = #CCList# & "," & getFormEmails.cc_email2 />
<cfelse>
<cfif getFormEmails.cc_email NEQ "">
<cfset CCList = #CCList# & "," &
getFormEmails.cc_email3 />
<cfelse>
<cfif getFormEmails.cc_email4 NEQ "">
<cfset CCList = #CCList# &
"," & getFormEmails.cc_email4 />
<cfelse>
<cfset CCList = #CCList# &
"," & getFormEmails.cc_email3/>
</cfif>
</cfif>
<cfset CCList = getFormEmails.cc_email1 />
</cfif>
</cfif>
<cfoutput>#CCList#</cfoutput>
I know I'm probably making this more difficult than it really is but I just
cannot see the trees for the forest right now and your help is needed and
much appreciated!
Thanks!
Bob
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4833
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15