Hi all,
Chad Renando wrote:
Hey all. I am looping through one query to create rows in a table,
and then, due to the first query having dynamic column names, looping
through another to create the columns. So:
<cfloop query="MyRowQuery">
<tr>
<cfloop query="MyColumnQuery">
<td>Stuff</td>
</cfloop>
</tr>
</cfloop>
Problem is that it is only spitting out the values from the first
record of MyRowQuery. So for example, if I manually spit out "Stuff"
before the MyColumnQuery, it shows the correct data for MyRowQuery,
like: Stuff1, Stuff2, Stuff3.
But when I try to output the data from MyRowQuery inside
MyColumnQuery, I get MyStuff1, MyStuff1,MyStuff1.
It a standard "scoping" issue due to the way CF handles queries inside
queries. You need to put the data that you want to show/use inside the
second loop into a variable scope variable in the first loop before you
get to the second loop. That make sense? (brain not allowed to work
properly on a Sunday).
Your code needs to look like:
<cfloop query="MyRowQuery">
<cfset thisRowVar = MyRowQuery.stuff>
<tr>
<cfloop query="MyColumnQuery">
<!--- thisRowVar - is now valid --->
<td>Stuff</td>
</cfloop>
</tr>
</cfloop>
Cheers,
Chad
who is risking being smitten by coding on the Sabbath
Don't worry, most of us would be charcoal by now if that was true :^)
Kym K
---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/