Link to home
Start Free TrialLog in
Avatar of kenjpete
kenjpete

asked on

Problem with looping over a SQL Query in Coldfusion

I am building a ColdFusion-based search results page where the visitor can select a checkbox next to each result for comparing two or more records on the page.

Once they click the submit button I need to be able to show just those records that were selected on a new page so that the visitor can compare the results against each other. The checkbox passes the ID of that record to a SELECT statement to build the query.

The problem I am having is each checkbox on the results page is called "compare" and passes each unique ID in the URL string to the comparison page as the same variable. So, how do I loop through each ID, pass it to my query, and output the result set on the new page?

One thought I had was to store each ID in an array and loop over the SQL query for each record in the array. But then how do I get that into one recordset that I can output to my comparison page?
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kenjpete
kenjpete

ASKER

I changed my query as you recommended but for some reason I am getting the following error:

[ODBC Microsoft Access Driver] Syntax error (comma) in query expression 'GrantID = 468,195,659'.
If I didn't mention it previously, I'm using a MS Access database and my ID field is set to Autonumber.
Ok I found the problem, I had an old query buried at the top of the page....disregard that syntax error problem. It works perfectly!