You might have gotten that message, but not when using the code below. 
I think I overlooked part of your OP though.  guestdetail is a query
object, and you are probably inside of a <cfoutput query=""> OR your
query object only has one record.  Is that correct?

If guestdetail is a query, the syntax I gave you below will actually
return an array of values for that column.  You will want to reference
the current record you are accessing as well like so:

<cfoutputquery="guestdetail">

    <cfloop from="1" to="4" index="idx">
    Guest #idx#: #guestdetail["guest" & idx][currentrow]#<br>
    </cfloop>

</cfoutput>


Or... if this result set has only one record, you can just do this:

 <cfloop from="1" to="4" index="idx">
Guest #idx#: #guestdetail["guest" & idx][1]#<br>
</cfloop>

~Brad

-------- Original Message --------
Subject: Re: Loop and Variable Names
From: Les Mizzell <[email protected]>
Date: Thu, January 08, 2009 10:40 am
To: cf-talk <[email protected]>

> <cfloop from="1" to="10" index="idx">
> Guest #idx#: #guestdetail["guest" & idx]#<br>
> </cfloop>

I had tried that, and got:

"Element GUEST is undefined in GUESTDETAIL"

But I can directly output #guestdetail.guest1# through 10 with no
problems.

Hmmmm


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317618
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to