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

Re: Translation of Variable Output From CFQUERY

$
0
0

I spoke too soon.  This worked in one case, but not in the following case:

 

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

dilemma, in a slightly different setting where I am attempting to retrieve a single record.

 

First, I define some variables:

 

<cfset datasource = 'MyDatabase'>
<cfset query_tbl = 'MyDatabaseTable'>
<cfset field1 = 'actual_fieldname1'><!--- FIRST field in MyDatabaseTable --->
<cfset field2 = 'actual_fieldname2'><!--- SECOND field in MyDatabaseTable --->
<cfset ID = #Form.ID#<!--- ONE particular record I want to retrieve, passed from a form --->

 

I do a test display to ensure all variables are set, and everything checks out fine.

 

Then, to retrieve this single record, I run a query using those variables:

 

<cfquery name="cfqGetItem" datasource="#datasource#">
  SELECT *
  FROM #query_tbl#
  WHERE ID = #ID#
</cfquery>

 

Then, I attempt to display the query output:

 

EITHER AS

 

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

 

OR, AS

 

<cfoutput>
  <p>#cfqGetItem[column1_field][currentRow]#
</cfoutput>

 

In each case, I get a similar CF error message: "Element field1 is not defined in query cfqGetItem", or "Variable currentrow is not defined".

 

How do I get the query output to generate the actual values for the record?

 

How can a "translation" be done?  What would be the correct way?

 

Thank you very much for any help!


Viewing all articles
Browse latest Browse all 21760

Trending Articles



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