Quantcast
Channel: Adobe Community : All Content - ColdFusion
Viewing all articles
Browse latest Browse all 5979

Translation of Variable Output From CFQUERY

$
0
0

I'm not highly technical, and this is probably something easy, but here is my

dilemma.

 

First, define some variables:

 

<cfset datasource = '#MyDatabase#'>
<cfset query_tbl = 'MyDatabaseTable'>
<cfset field1 = 'actual_fieldname'><!--- a field in MyDatabaseTable --->

 

Then, run a query using those variables:

 

<cfquery name="cfqGetItems" datasource="#datasource#">
  SELECT *
  FROM #query_tbl#
  ORDER by #field1# ASC
</cfquery>

 

Then, attempt to display the query output:

 

<cfoutput>
  <p>#cfqGetItems.field1#
</cfoutput>

 

Insead of the values for "actual_fieldname", I get an error message: "field1 is not defined in query cfqGetItems".

 

I realize that defining the output as "#cfqGetItems.field1#" is incorrect, but how can a "translation" be done?  What is the correct way to get the output to generate the values for "actual_fieldname" instead of thinking it is still dealing with the variable "field1"?

 

Thank you very much for any help!


Viewing all articles
Browse latest Browse all 5979

Trending Articles



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