Let's say that you had a query that lists every Starbucks in the USA and you
wanted to output the list grouped by state.

Your outer cfoutput would set a 'group' attribute by state and display the
state name. Your inner cfoutput would output the physical store location.
There are certainly other ways to do the same thing, but this one is the
elegant choice.



-----Original Message-----
From: Todd Mathews [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 18, 2007 6:56 PM
To: CF-Talk
Subject: LOOPY LOOP LOOP


Here is a fun one that I somehow missed in the past...

We were looking at some code that appeared to be looping over itself and
tracked it down to an extraneous <CFOUTPUT> clause inside the parent
<CFOUTPUT QUERY..> loop.
 
Here is a quick example:

<cfoutput query="getItems">
#getItems.itemId#<br>
</cfoutput>
 
Outputs the item id numbers as expected..
IE:
1
2
3
4

Now try this:
 
<cfoutput query="getItems"> <cfoutput>#getItems.itemId#</cfoutput><br>
</cfoutput>

The second version outputs a loop of the items in a loop of the records.. 
IE:
1234
234
34
4

Although this does make some sense, it seems strange that the second
cfoutput is indeed interacting with the parent cfoutput loop but not like
one might expect.

Of course the obvious solution is to avoid extraneous CFOUTPUTs, but I
thought it might be helpful to post in case anyone else encounters a similar
issue in the future. 

This behavior occurs in both CFMX 7 and CFMX 8 FWIW.

Nothing earth shattering here.. Just one of those nuances that makes you
feel a little crazy from time to time. ;)

For fun, can anyone come up with a scenario where this type of behavior is
actually DESIRED instead of both outputting the same results like might be
expected?

Todd





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288779
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to