> On Sun, 27 Mar 2005 15:06:43 -0500, Andrew Tyrone <[EMAIL PROTECTED]>
> wrote:
> > I might be crazy, but I seem to remember, at least in CF 4.x versions,
> that
> > if you scoped a query column within a cfoutput, it would only output the
> > data in the first row of the query, not the current row, no matter where
> you
> > were in the loop.

Matt's right here, the basic rule doesn't change depending on scope, it
changes on situation.

If your looping over the query (with a cfoutput or cfloop using the query
attribute) then doing "queryname.fieldname" will always output the current
row's value.

If you're not looping over a query then "queryname.fieldname" will always
return the value of the first row as if you said "queryname.fieldname[1]".

The odd thing is with queries should you use indexed notation you get a
different value.  While the value of "queryname.fieldname" is the value of
the first row the value of "queryname["fieldname"]" is actually a reference
the column - essentially a one dimensional array containing all of the rows
values.

For most everything you can use this as an array.  To get the sum of a query
column, for example, you can do ArraySum(queryname["fieldname"]).

This is a very powerful feature - but test it first.  CFMX had some minor
bugs with this related to the fact that in some cases it counted the array
from zero (as Java) and not from one (as CF).

Just to plug much of this information comes from my guide to CFML variables.
It's actually long overdue for a clean up (many of the links inside it are
dead and some information has changed since CF 6.0) but it's still rather
good if I do say so myself:

http://www.depressedpress.com/DepressedPress/Content/Development/ColdFusion/
Guides/Variables/Index.cfm


Jim Davis




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:200156
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to