Question

I'm going through a query in which there are 12 entries named "choice_1" through "choice_12." I want to be able to dynamically call an individual choice depending where it is in the loop. So here is the query:

<CFQUERY DATASOURCE="tr3" NAME="qryUserMatchPref"> 
    SELECT *
FROM UsrMatchPrefTR2
WHERE session = #sess# AND site = #siteFirst# AND user_id = #tempUser#
</CFQUERY>

And let's say the loop is on it's third run and I wanted to check choice_3, I would want in theory to do something like this.

<cfset combined = "choice_" & counterChoice>
<cfset tempMatch = qryUserMatchPref.#combined#>

I would of course be querying for choice_3, if counterChoice is equal to 3, and not for what ever is in the "combined" column [doesn't exist in this case]. Is there a way to do this in coldfusion or am I doomed to create a very tedious series of if statements? D:

Was it helpful?

Solution

you should just be able to do

qryUserMatchPref[combined][currentRow]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top