You didn't say what version of CF you were using but in later versions
(4.5 and above) you can access queries much more easily via index
notation. So your snippet would be something like:
<cfloop list="#Stats.ColumnList#" index="Cols">
<cfoutput>#Stats[Cols][CurrentRow]#</cfoutput>
</cfloop>
There's more information on Index notation in my guide to CF variables
here:
http://www.depressedpress.com/DepressedPress/Content/ColdFusion/Guides/V
ariables/NotationIndexed.cfm
Hope this helps,
Jim Davis
> -----Original Message-----
> From: Antony Sideropoulos [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 03, 2003 9:12 PM
> To: CF-Talk
> Subject: Referring to 'unknown' query columns
>
>
> Hello
>
> BACKGROUND:
>
> I have designed a 'Transform' query as part of an intranet
> usage reporting
> tool. I display the user, the total number of hits, and then
> the hits per
> page. When someone runs this report, they have the option to
> limit the
> pages reported on - ie only the general pages, only the admin pages...
>
> Therefore, the query will have a different number of columns,
> and different
> column headings.
>
> If I CFDUMP the query, the results display correctly, but I
> don't have any
> control over layout.
>
> Therefore, what I want to do is output the data myself.
>
> THE PROBLEM:
>
> How do I programatically output query data, using the values in
> query.ColumnList?
>
> I have done a search in the archives, and found this example
> which I have
> been unable to get to work:
>
> <cfloop list="#Stats.ColumnList#" index="Cols">
> <cfset currentColumn = Evaluate("Stats" & Cols)>
> #currentColumn #
> </cfloop>
>
> (where Stats is my query name)
>
> I get an error like this:
>
> An error occurred while evaluating the expression:
>
> currentColumn = Evaluate("Stats." & Cols)
>
> Now, it could be that the error arises when the column name
> includes spaces
> (eg Budget Report).
>
> Can someone give me some tips about this before I go back and
> take all the
> spaces out of the existing data and modify my hit-recording code?
>
> Is there a way to refer to a column by a number? eg Stats.[1]?
>
> If you can make any sense out of the above and can advise me
> I would be most
> grateful.
>
> (I'm using CF5.0)
>
> Thanks
>
> Antony
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4