Dynamic variable names??? Please Help!

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Dynamic variable names??? Please Help!

    So I'm making this application for accessing research data - lots of different
    data tables, each with it's own data columns.

    I have made the interface where the user can pick which data columns to
    download. This produces a list of table columns to be fetched by the database -
    I pass this on to the SQL query, and get back the result. But how do I output
    that, without hard-coding the names of the data columns?

    <cfoutput query="qData">
    #qData.col1#,#qData.col2#,#qData.col3#
    </cfoutput>

    The above would be fine, but I don't know which of the many columns have been
    selected - they are stored in the list variable, and also in qData.ColumnList,
    but I can't figure out how to use the list contents to tell cfoutput what to
    output. Is there a way to make it output all the columns in a query, withouit
    specifying their names?

    Thanks,

    y

    Yavka Guest

  2. Similar Questions and Discussions

    1. Javascript variable names in strings
      This should be easy, but i can't find any info on how to do it! It's easy to put the contents of a variable into a string but how does one place...
    2. Assign Array with Dynamic Variable Names
      I have an 2 dimensional array that I want to assign to an 1 dimensional array with a dynamic Variable Name. I can set the newarray function, but I...
    3. possible to read flashvars if variable names are not known?
      When passing arguments from the embedding HTML page to the Flash movie you can use flashvars e.g. <embed flashvars="arg1=1&arg2=2" ...> and then...
    4. variable movie names
      your all superstars! a pair of square brackets are what were required- the top answer worked first time, so thanks guys for all your help. morgn.
    5. Dynamic Variable Names
      I have a shopping cart page that allows a user to type in a new quantity and press a button. The quantities entered are in form text boxes with...
  3. #2

    Default Re: Dynamic variable names??? Please Help!

    <cfoutput query="qData">
    <cfloop list="#qData.columnList#" index="col">
    #qData[col][currentRow]#
    </cfloop><br>
    </cfoutput>

    mxstu Guest

  4. #3

    Default Re: Dynamic variable names??? Please Help!

    Yes, this works. Thanks a bunch!

    I see now how it works - it's so simple, I would have never thought of it! I
    wish they had stuff like this clearly explained in the documentation. Or could
    you recommend a good book?

    :-) :-) :-)

    Yavka Guest

  5. #4

    Default Re: Dynamic variable names??? Please Help!

    Yes, it would be nice but I guess it is hard to document *every* usage of every available feature! I'm not that up on the recent books but you might want to search the forums for recommendations.
    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139