I have a query that returns all data from a table
I then have a sub query that defines which columns should be output on the screen.
I want to be able to output data columns from the first query based on the relevant cols in the output data.
I then try to output these in a table
This returns all output cols with the same data in each record.
I am sure this is possible but cannot see how to do it.
I have tried converting to list and arrays the output cols data but still cannot get it to work.
Any suggestions?
The tables would look like this:
I then have a sub query that defines which columns should be output on the screen.
I want to be able to output data columns from the first query based on the relevant cols in the output data.
Code:
<cfquery datasource="#DSN#" name="allData">
SELECT *
FROM AllData
</cfquery>
<cfquery datasource="#DSN#" name="outputCols">
SELECT ColRef
FROM ColsData
WHERE Output = 1
</cfquery>
Code:
<cfoutput query="allData">
<td>#field1#</td>
<td>#field2#</td>
<cfloop query="outputCols">
<cfset x = "allData." & #ColRef#>
<td>#evaluate(x)#</td>
</cfloop>
</cfoutput>
I am sure this is possible but cannot see how to do it.
I have tried converting to list and arrays the output cols data but still cannot get it to work.
Any suggestions?
The tables would look like this:
Code:
All Data
Field1 Field2 Field3 Field4 Field5 Field6
1 a d g j m
2 b e h k n
3 c f i l o
OutputCol
ColRef Output
Field3 1
Field4 1
Field3 2
Field5 2
Field6 2