Wondering if you can help me. I have a friend who is generating a list from check boxes on a form. He then wants to retrieve clients who subscribe to newsletters based on the list, it's been 10 years since I've done any programming and I can’t remember how to do it.
This is what he has:
<cfoutput>
<cfset coldfusion_list = "#recipientlist#">
#listLen(coldfusion_list)# [highlight #A40000]<!---In testing this returns 8 elements as it should – These elements are Newsletter ID numbers (15395,15399,15400,15404,15408,15409,15425,15423)--->[/highlight]
</cfoutput>
<cfloop index = "ListElement" list = "#coldfusion_list#">
<cfquery name="getclients" datasource="#db#">
Select clientemail
FROM VIEW_SendNotification
WHERE newsletterid IN (#ListElement#)
[highlight #CC0000]<!—This WHERE statement is his problem – He wants to retrieve users if they match any of the newsletter ID’s. In this case they have to match ALL newsletter ID’s and I can’t remember how to loop over the list.
Here’s what he wants it to do – WHERE newsletterid = ‘15395’ OR newsletterid = ‘15399’ OR newsletterid =’15400’ OR newsletterid =’15404’ OR newsletterid = ‘15408’ OR newsletterid =’15409’ OR newsletterid =’15425’ OR newsletterid =’15423’[/highlight]
</cfquery>
</cfloop>
<cfoutput query="getclients">#clientemail#<br /></cfoutput>
This is what he has:
<cfoutput>
<cfset coldfusion_list = "#recipientlist#">
#listLen(coldfusion_list)# [highlight #A40000]<!---In testing this returns 8 elements as it should – These elements are Newsletter ID numbers (15395,15399,15400,15404,15408,15409,15425,15423)--->[/highlight]
</cfoutput>
<cfloop index = "ListElement" list = "#coldfusion_list#">
<cfquery name="getclients" datasource="#db#">
Select clientemail
FROM VIEW_SendNotification
WHERE newsletterid IN (#ListElement#)
[highlight #CC0000]<!—This WHERE statement is his problem – He wants to retrieve users if they match any of the newsletter ID’s. In this case they have to match ALL newsletter ID’s and I can’t remember how to loop over the list.
Here’s what he wants it to do – WHERE newsletterid = ‘15395’ OR newsletterid = ‘15399’ OR newsletterid =’15400’ OR newsletterid =’15404’ OR newsletterid = ‘15408’ OR newsletterid =’15409’ OR newsletterid =’15425’ OR newsletterid =’15423’[/highlight]
</cfquery>
</cfloop>
<cfoutput query="getclients">#clientemail#<br /></cfoutput>