Skip to main content
Participant
January 13, 2010
Answered

Dynamic Query Output

  • January 13, 2010
  • 1 reply
  • 395 views

Hey everybody, have a quick question. I just started using ColdFusion last week for my current job and I'm doing some database work. One of the scripts I'm working on is to dynamically allow a user to enter in information for a data source, their username, password, a database, and then a Query-By-Example-esc operation on that database. One issue I'm running into though is displaying this data. So, let's say that I get input from a simple HTML form and it's being passed in under the name "Column_1". So, when I go to access it for my SQL statement, I would be using:

#Form.Column_1#

My problem comes to when I am printing this data out. I'm using the following code normally:

<cfoutput query="GetResults">
     #username#
</cfoutput>

Where #username# is the column I was searching for. How would I be able to dynamically have it output whatever would be entered as the column name in Column_1? So something like:

<cfoutput query="GetResults">
     # #Form.Column_1# #
</cfoutput>

Thanks!

This topic has been closed for replies.
Correct answer Dan_Bracuk

array notation is your freind.

queryname["columname"][row number]

or, in your case,

queryname["#variable for columname#"][row number]

1 reply

Dan_BracukCorrect answer
Inspiring
January 13, 2010

array notation is your freind.

queryname["columname"][row number]

or, in your case,

queryname["#variable for columname#"][row number]

SaviorXAuthor
Participant
January 13, 2010

Thanks a lot, I'll give that a try tomorrow.