Answered
Parse form variable to insert in my query
I have a report where I want to group my output. The only
problem is the field I want to group by comes in as a comma
deliimeter from the form.
If I use the in() function it doesnt group the output correctly.
<cfoutput>#form.id#</cfoutput><br><br>
<cfquery name="que" datasource="mydsn">
SELECT *
FROM myTable
WHERE id in (#form.id#)
</cfquery>
<cfoutput query="que" group="id">
#id#<br>
<cfoutput>#name#<br></cfoutput>
</cfoutput>
Output -
2
Jones
2
Smith
But if I use one form value at a time it correctly groups my output:
<cfquery name="que" datasource="mydsn">
SELECT *
FROM myTable
WHERE id = 6
</cfquery>
Output -
2
Jones
Smith
Please advise how I can take the form values and input them one at a time in my cfquery?
I assume I need to parse the form.id output and then loop through each value to insert into my cfquery but not sure how I can do this?
If I use the in() function it doesnt group the output correctly.
<cfoutput>#form.id#</cfoutput><br><br>
<cfquery name="que" datasource="mydsn">
SELECT *
FROM myTable
WHERE id in (#form.id#)
</cfquery>
<cfoutput query="que" group="id">
#id#<br>
<cfoutput>#name#<br></cfoutput>
</cfoutput>
Output -
2
Jones
2
Smith
But if I use one form value at a time it correctly groups my output:
<cfquery name="que" datasource="mydsn">
SELECT *
FROM myTable
WHERE id = 6
</cfquery>
Output -
2
Jones
Smith
Please advise how I can take the form values and input them one at a time in my cfquery?
I assume I need to parse the form.id output and then loop through each value to insert into my cfquery but not sure how I can do this?
