Claus Spitzer
Claus Spitzer

Reputation: 34

Coldfusion: How to print out data from query

I'm trying to make a configureable print out of a query.

<cfloop query="#query_name#">
   <tr class="tabledetail">
       <cfloop array="#col_db_names#" index="colname">
           <td valign="middle" class="detaildata" nowrap>
               #query_name#.#colname#
           </td>
       </cfloop>
    </tr>
</cfloop>

The problem is, that i can't figure out how to display the data now, because i only get this output:

enter image description here

Thank you for your help, I'm still quite new to ColdFusion.

Upvotes: 0

Views: 325

Answers (1)

Adrian J. Moreno
Adrian J. Moreno

Reputation: 14859

I would suggest you go through https://www.learncfinaweek.com/ if you need help with the language. Looks like you've got the basic concepts of how to organize the output. I thought it was missing the actual <cfoutput> tags, but then I realized the syntax inside the <td> tags.

#query_name#.#colname#

This is evaluating the two variables separately. The query name and the column name from the array. This is why you're seeing the names of each column in the HTML table.

The syntax to reference the column name as an element of the query is

#query_name[colname]#

This should output the data in each column in the HTML table cells.

Upvotes: 5

Related Questions