Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
brokerandy25 #1
Running a query with multiple lists
Any help would be so appreciated, I have beat my head against the wall on this
one and have scoured the web trying to find an answer. I am trying to build an
email program for a client that will allow them to issue press releases. The
trick is that they need to be able not only to select multiple counties in the
state, but then they need to select what type of media they send it to (also
multiple media oultets). NOTE my state has 95 counties, and there are 3 press
outlets, web, print and radio/ tv. I can use radio buttons for the press
outlets, and build a query using the ifDefined then and use OR in the query,
but how can I pass a list to a query? I think that the query should look
something like this <cfquery name'PressRelease' datasource='name'> SELECT
Name, EmailAddress From PressReleaseEmail WHERE County = XXXXXXXXXXXX AND
MediaType = <cfif isDefined ('Form.Print')> '#Form.Print#' <else> NULL
</cfif> <cfif isDefined ('Form.WEB')> OR '#FORM.WEB#' <esle> NULL </cfif> <cfif
isDefined ('Form.Radio')> OR '#Form.Radio#' <else> NULL </cfif> So the query
can be dynamically built from the radio buttons. but how does do I pass the
list from FORM.County into the query? All help will be wonderful. Andy
brokerandy25 Guest
-
writing content of multiple lists to db
I have a time reporting app that contains five elements, staff, date, CR (job) category (activity) and hrs. Since each staff person can work... -
'or' selection from multiple lists
Hey, I am trying to set up a selection where a user can choose from one or multiple drop downs and choose as many within a box as they want. ... -
Problem combing multiple lists into one
I have three lists (m1,m2,m3) and I need to combine them into one list (m4): <cfset m1 = valuelist(search2.cat)> <cfset m2 =... -
CAML Query: Multiple Query Fields Issue
I need to Create a CAML Query Dynamically with VB to a Sharepoint WebService GetListItems Method. The User Could Select 1 to X Number of IDs... -
dropdown lists - query parameter error
Hi, I'm using the following for 2 dropdown boxes in asp.net. The first is the basis for the contents of the second. First works fine, then on... -
Maneesh Tikkiwal #2
Re: Running a query with multiple lists
Hope it helps. I m pretty sure it will work if u play around a bit, in case of
any errors.:beer;
<!--- assuming u are using multiple select box which names Counties
<cfselect name="Counties" multiple="Yes">
<cfoutput query="allCounties">
<option value="countyname">#countyname#</option>
</cfoutput>
</cfselect>
--->
<!--- when u submit the form above, u will have a values (as list) in
form.Counties
which should look like this a,b,c,d,e,f u can check it by using
<cfoutput>#form.Counties#</cfoutput> --->
<!--- please note the variable below 'CountyName', will become the list
element. so, it will run the query
and compare the value one by one, eg. first a, then b, then c and so on. --->
<cfloop index="CountyName"
list="#form.Counties#">
<cfquery name"PressRelease" datasource="name">
SELECT Name, EmailAddress From PressReleaseEmail WHERE
County = #CountyName# AND MediaType =
<cfif isDefined ('Form.Print')>
'#Form.Print#'
<else>
NULL
</cfif>
<cfif isDefined ('Form.WEB')>
OR '#FORM.WEB#'
<esle>
NULL
</cfif>
<cfif isDefined ('Form.Radio')>
OR '#Form.Radio#'
<else>
NULL
</cfif>
</cfquery>
</cfloop>
Maneesh Tikkiwal Guest
-
brokerandy25 #3
Re: Running a query with multiple lists
I knew I had to loop through the query, just couldn't figure out the syntax,
you are a life saver. Some times the simplest answers are the hardest to find
.. . . . . do I have to use the cfselect tag or can I use the html select tag?
brokerandy25 Guest
-
Maneesh Tikkiwal #4
Re: Running a query with multiple lists
no worries.
it doesn't matter what u use, cfselect or html select. both will give u the desired result.
Maneesh Tikkiwal Guest
-
Adam #5
Re: Running a query with multiple lists
CFLOOP surrounding the query is kind of inefficent.
What about using SQL's IN statement which repsents an OR list
You could do this
<!---- surrounds each country with single quote for SQL ---->
<cfset lstCountries = chr(34) & Replace(FORM.Countries, ',', chr(34) & ","
chr(34), All) & chr(34) >
<cfquery name"PressRelease" datasource="name">
SELECT Name, EmailAddress From PressReleaseEmail
WHERE County IN(#PreserveSingleQuotes(lstCountries)#)
AND MediaType =
<cfif isDefined ('Form.Print')> '#Form.Print#' <else> NULL </cfif>
<cfif isDefined ('Form.WEB')> OR '#FORM.WEB#' <esle> NULL </cfif>
<cfif isDefined ('Form.Radio')> OR '#Form.Radio#' <else> NULL </cfif>
</cfquery>
I think ASCII code 34 is the ' sign, this works in SQL Server, don't do much
with Access but it should support the IN command and you would of course use
double quotes.
This way you don't potentially open 95 select statements on the server.
"Maneesh Tikkiwal" <webforumsuser@macromedia.com> wrote in message
news:d48hon$i5o$1@forums.macromedia.com...> no worries.
>
> it doesn't matter what u use, cfselect or html select. both will give u
> the desired result.
Adam Guest



Reply With Quote

