Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: Translation of Variable Output From CFQUERY

$
0
0

Ok, so here's what you would do usually, as you know:

 

<cfoutput>#cfqGetItems.actual_fieldname#</cfoutput>

 

Logically this is wrong, but ColdFusion behaviour won't give you an error if your query returns several rows - instead you just see the result of the first returned row. This is how CF operates when using the basic syntax.

 

If you want to evaluate the field name, say goodbye to that shortcut, and address the query columsn as arrays (of row values).

 

<cfoutput>#cfgGetItems[field][1]#</cfoutput> Would give you similarly the result of the first row,

 

When looping over a query, (which is actually what you want to do, I'm sure) you have a couple of options, which both are shown below:

 

<cfoutput query="cfqGetItems">

#evaluate(field1)# = #cfgGetItems[field1][currentrow]#<br>

</cfoutput>

 

HTH, -Fernis


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>