Skip to main content
Participating Frequently
February 19, 2009
Question

programming question

  • February 19, 2009
  • 7 replies
  • 586 views
I have a program starting with the following codes:

<cfset cols='red,blue,yellow'>
<cfquery datasource="datasource" name="name">
select #cols# from a_table
</query>

My question is, how can I display the queried dataset without referencing the elements in cols?

Regards!
    This topic has been closed for replies.

    7 replies

    Inspiring
    February 27, 2009
    evaluate()? who needs eveluate() when you have associative array notation?

    use this instead:

    <cfoutput query="query_name">
    <cfloop list="#query_name.columnlist#" index="col">
    #query_name[col][currentrow]#
    </cfloop>
    </cfoutput>

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Participating Frequently
    February 27, 2009
    Hey! Sorry, due to error messages, I refreshed the page twice and the same message was sent thrice. I couldn't find a delete option for it. Apologies for the inconvenience.
    Participating Frequently
    February 27, 2009
    If you are still looking for a reply, here it is:
    Column name for the query is user input so you can this code to display the queried data as follows which is independent from column names:
    <cfoutput query="query_name">
    <cfloop list="#query_name.columnlist#" index="i">
    #evaluate(i)#
    </cfloop>
    </cfoutput>

    Hope this helps!
    Participating Frequently
    February 27, 2009
    If you are still looking for a reply, here it is:
    Column name for the query is user input so you can this code to display the queried data as follows which is independent from column names:
    <cfoutput query="query_name">
    <cfloop list="#query_name.columnlist#" index="i">
    #evaluate(i)#
    </cfloop>
    </cfoutput>

    Hope this helps!
    Participating Frequently
    February 27, 2009
    If you are still looking for a reply, here it is:
    Column name for the query is user input so you can this code to display the queried data as follows which is independent from column names:
    <cfoutput query="query_name">
    <cfloop list="#query_name.columnlist#" index="i">
    #evaluate(i)#
    </cfloop>
    </cfoutput>

    Hope this helps!
    NatomasAuthor
    Participating Frequently
    February 19, 2009
    I can't use cfdump.

    There are two reasons I ask this question. First, a dataset can have many columns and specifying each of them in cfoutput can be pretty tedious. Second, and more important, which columns of the data to be displayed is a user's input.

    Ian Skinner offers a very quick solution to this problem. You can find it under the same topic in the Advanced Techniques thread.

    Regards!
    Inspiring
    February 19, 2009
    cfdump will display it.

    If you want something using cfoutput, at some point you'll have to reference something.

    Why do you ask?