dynamic - Double evaluation - How do I access my query column based on a variable that holds the column name? -


i have query , list of field/column names. want sort of double loop - loop through each record in query, , loop through list of field/column names , output each corresponding field. loops should this:

<table>     <cfoutput query="myquery">         <tr>             <cfloop list="#cols#" index="col">                 <td>?</td>             </cfloop>         </tr>     </cfoutput> </table> 

the problem put question mark is... i've tried #myquery[col]#, didn't work. need variable indicated string name in variable col... , obviously, #col# return column name. need figure out way double-evaluate string... ##col##, of course won't work either. how can accomplish this?

when referencing column names structure, need tell query row want get. should make sure check column name exists if didn't cols variable via myquery.columnlist.

use following code dynamically reference each column in loop:

<table>     <cfoutput query="myquery">         <tr>             <cfloop list="#cols#" index="col">                 <td>#myquery[col][currentrow]#</td>             </cfloop>         </tr>     </cfoutput> </table> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -