Help with variable query?

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Help with variable query?

    I'm having an arbitrary query input by the user, then to make that query into
    an excel file it must be put into a table similar to below. Since I don't know
    the number of columns necessarily i use ListLen(), and since I don't
    necessarily know the names of all the colums i use <cfloop>. I am able to put
    all the names of the columns into an excel file in this way (by using "i"
    instead of "OSFAres.i").

    Basically all of this works except the part with "OSFAres.i". An error is
    thrown "no member i exists of query OSFAres" even though "i" should hold the
    name of one of the columns. Basically I need to find a way to force the server
    to evaluate i before it evaluates OSFAres.i.



    <table cols="#ListLen(OSFAres.ColumnList)#">
    <cfoutput query="OSFAres">
    <tr>
    <cfloop LIST="#OSFAres.ColumnList#" index="i">
    <td>#OSFAres.i#</td>
    </cfloop>
    </tr>
    </cfoutput>
    </table>

    Bukzor Guest

  2. Similar Questions and Discussions

    1. PARSING A QUERY OF QUERY WITH A VARIABLE VALUE
      On my first page the user selects a project. I am using the variable SelectedProject: <cfset SelectedProject =...
    2. Using a Variable to create the SQL Query
      I need to create a "dynamic" Update query. I want to store the meet of the command in a variable and then reference the variable in in query. ...
    3. Passing a variable to a query
      <cfset ctr=1> <cfloop list="#query1#" index = "i" delimiters = ","> <cfset thisColumn = "subcat_"&#ctr#> <cfquery name="insertNodes"...
    4. Using variable in sql query
      Hello again, I'm trying to run an sql query using a string as in the following: <cfset string = "address1=' #evaluate("form.param#count#")# ',...
    5. Variable Syntax Query
      I'm building a button bank of 6 buttons whereby pressing one button releases the last button activated. Each button is it's own movie clip named...
  3. #2

    Default Re: Help with variable query?

    <cfloop LIST='#OSFAres.ColumnList#' index='i'>
    <td>#i#</td>
    </cfloop>

    gwgiswebmaster Guest

  4. #3

    Default Re: Help with variable query?

    gwgiswebmaster:

    That does does run without error, but it puts the titles of the columns in the table, not the data from the query.
    Bukzor Guest

  5. #4

    Default Re: Help with variable query?

    sorry, misunderstood exactly what you were going for, try this: <cfoutput>
    <table> <tr> <cfloop LIST='#OSFAres.ColumnList#' index='i'>
    <td>#i#</td> </cfloop> </tr> <cfloop query='OSFAres'> <tr> <cfloop
    LIST='#OSFAres.ColumnList#' index='i'> <td>#Evaluate('OSFAres.' &amp;
    i)#</td> </cfloop> </tr> </cfloop> </table> </cfoutput>

    gwgiswebmaster Guest

  6. #5

    Default Re: Help with variable query?

    thankyou thankyou

    exactly what i was looking for :)
    Bukzor 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