Not sure if this is possible or not. What I am trying to do is build an output string via queries. I am concatenating the output "name" and appending the "value" to the end. Then outputting the string. I don't think this is possible. But I am looking for any alternatives.
So this is what I have:
qry1
is the main query. qry2
gets the value to append to the end of the string.
So the value of variable test
would look like this: "variables.qry1.100"
Which would make sense to qry1
as this is part of the query object. So then this string would return a correct value from the database as there is a subquery called 100
<cfoutput>
<cfloop query="variables.qry2">
<cfset test = variables.qry1. & variables.qry2.#valueID#>
<td>#test#</td>
</cfloop>
</cfoutput>
Many thanks.
JC
What your trying to do is possible, but you need to build a variable name first.
Instead of
<cfset test = variables.qry1. & variables.qry2.#valueID#>
Try
<cfset test = "variables.qry1.#variables.qry2.valueID#">
Test will then be variables.qry1.[valueID value]
. Note that [valueID value] is what is getting returned from the query, so the actual value inside the variable.
Then to display the value of variables.qry1.[valueID value]
.
#evaluate(test)#
UPDATE As stated by Adam Cameron's answer. You should really try to avoid the evaluate()
function, it's quite a performance hit and not considered good practice. Instead rather use the following code (This is copied from Adam Cameron's answer)
#variables.qry1[variables.qry2.valueID][1]#
NOTE: Go look at Adam Cameron's answer for a better description of whats going on.