Hi, Roger,

What do you want to achieve? Do you want the inner loop repeat the out
loop's output ? Then how many times? This will give you the times EQ to the
second query's recordcount.

Sima
----- Original Message -----
From: Roger Lim <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 13, 2000 9:19 PM
Subject: Re: Multiple <CFLOOP>s


> Hi,
>
> That's what I'm facing right now, apparently I do not understand why is it
> so. Under your example, for the second time it looped, why the Second Loop
> show "John" and not "Smith"?
>
> I tried to use the following method to solve this problem:
>
> <cfloop query="query_a">
>     <cfoutput>#query_a.field_a#<cfoutput>
>     <cfset display_a = #query_a.field_a#>
>         <cfloop query="query_b">
>                 <cfoutput>#variables.display_a#<cfoutput>
>         </cfloop>
> </cfloop>
>
> In that case, the second loop will follow the result of that in the first
> loop. What do you think?
>
> Roger
> ----- Original Message -----
> From: "Sima Lee" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, September 14, 2000 2:18 AM
> Subject: Re: Multiple <CFLOOP>s
>
>
> > Hi, the inner loop should always print out " 1". Because in the inner
loop
> > you loop through the second query not the first one and it simply excute
> the
> > statement : <cfoutput>#query_a.field_a#<cfoutput> as many time as the
> second
> > query's recordcount.
> > I have an example here:
> >
> > <cfset Customer =
> >
>
Querynew("SenderName,RecipientName,Subject,SenderEmail,RecipientEmail,Messag
> > e")>
> >
> > <cfset TempCust = QueryAddRow(Customer)>
> >
> >
> > <cfset TempCust = QuerySetCell(Customer, "SenderName", "John")>
> > <cfset TempCust = QuerySetCell(Customer, "RecipientName"," Mary")>
> > <cfset TempCust = QuerySetCell(Customer, "Subject", "Dinner")>
> > <cfset TempCust = QuerySetCell(Customer, "SenderEmail",
> "[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(Customer, "RecipientEmail",
> > "[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(Customer, "Message", "arange a dinner
> > together")>
> >
> > <cfset TempCust = QueryAddRow(Customer)>
> >
> >
> > <cfset TempCust = QuerySetCell(Customer, "SenderName", "Smith")>
> > <cfset TempCust = QuerySetCell(Customer, "RecipientName"," Black")>
> > <cfset TempCust = QuerySetCell(Customer, "Subject", "Dinner")>
> > <cfset TempCust = QuerySetCell(Customer, "SenderEmail",
> "[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(Customer, "RecipientEmail",
> > "[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(Customer, "Message", "arange a dinner
> > together")>
> >
> >
> > <cfset
> >
>
cftalk=QueryNew("SenderName,RecipientName,Subject,SenderEmail,RecipientEmail
> > ,Message")>
> >
> > <cfset TempCust = QueryAddRow(cftalk)>
> >
> >
> > <cfset TempCust = QuerySetCell(cftalk, "SenderName", "John")>
> > <cfset TempCust = QuerySetCell(cftalk, "RecipientName"," Mary")>
> > <cfset TempCust = QuerySetCell(cftalk, "Subject", "Dinner")>
> > <cfset TempCust = QuerySetCell(cftalk, "SenderEmail",
"[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(cftalk, "RecipientEmail",
> > "[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(cftalk, "Message", "arange a dinner
> > together")>
> >
> > <cfset TempCust = QueryAddRow(cftalk)>
> >
> >
> > <cfset TempCust = QuerySetCell(cftalk, "SenderName", "Smith")>
> > <cfset TempCust = QuerySetCell(cftalk, "RecipientName"," Black")>
> > <cfset TempCust = QuerySetCell(cftalk, "Subject", "Dinner")>
> > <cfset TempCust = QuerySetCell(cftalk, "SenderEmail",
"[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(cftalk, "RecipientEmail",
> > "[EMAIL PROTECTED]")>
> > <cfset TempCust = QuerySetCell(cftalk, "Message", "arange a dinner
> > together")>
> >
> >
> >
> >
> > This is the Cftalk example:<br>
> > <cfloop query="Customer">
> >     <cfoutput>Firt loop:#Customer.SenderName#</cfoutput><br>
> >         <cfloop query="cftalk">
> >                 <cfoutput>Second
loop:#Customer.SenderName#</cfoutput><br>
> >         </cfloop>
> > </cfloop>
> >
> >
> > /*The out put:
> >
> > Firt loop:John
> > Second loop:John
> > Second loop:John
> > Firt loop:Smith
> > Second loop:John
> > Second loop:John*/
> >
> >
> > Sima
> > ----- Original Message -----
> > From: Stephen Moretti <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, September 13, 2000 7:42 AM
> > Subject: RE: Multiple <CFLOOP>s
> >
> >
> > > >
> > > > I have 2 queries which require to loop through for certain
execution.
> > > > However I discovered something
> > > >
> > > > <cfloop query="query_a">
> > > >     <cfoutput>#query_a.field_a#<cfoutput>
> > > >         <cfloop query="query_b">
> > > >                 <cfoutput>#query_a.field_a#<cfoutput>
> > > >         </cfloop>
> > > > </cfloop>
> > > >
> > > > I realised that both #query_a.field_a# are different values, for the
> > first
> > > > one, it is able to list out all the different values. However for
> > > > the second
> > > > one, it only output the first value throughout.
> > > >
> > > > Is it something to do with multiple <cfloop>s ?
> > > >
> > > > Can somebody enlighten me on this ?
> > > >
> > >
> > > Eh....
> > >
> > > OK - if you get this result set from your query a and query b :
> > >
> > > QueryA  QueryB
> > > FieldA  Yourfield
> > > 1   a
> > > 2       b
> > > 3       c
> > >
> > > What you're going to get output is this:
> > > * 1
> > > 1
> > > 1
> > > 1
> > > * 2
> > > 2
> > > 2
> > > 2
> > > * 3
> > > 3
> > > 3
> > > 3
> > >
> > > The rows marked with a * are displayed in the outer loop and the other
> are
> > > displayed in the inner loop.
> > >
> > > The reason for this is that your inner loop is only going to loop
round
> > the
> > > contents of QueryB and output the _current row_ from QueryA. On the
> first
> > > iteration of the loop on QueryA the displayed result is "1", then the
> > inner
> > > loop iterates through QueryB, but doesn't move onto the next record in
> > > QueryA.  This means that for every iteration of QueryB on the first
time
> > > round the QueryA loop you'll only get the result "1".
> > >
> > > Are you sure that you have specified your code snippet correctly and
is
> > > there something else that you are doing in the loop that is missing
from
> > the
> > > above snippet???
> > >
> > > Regards
> > >
> > > Stephen
> > >
> >
>
> --------------------------------------------------------------------------
> > ----
> > > Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> > > To Unsubscribe visit
> > http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
or
> > send a message to [EMAIL PROTECTED] with 'unsubscribe'
in
> > the body.
> >
>
> --------------------------------------------------------------------------
> ----
> > Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> > To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
> send a message to [EMAIL PROTECTED] with 'unsubscribe' in
> the body.
>
> --------------------------------------------------------------------------
----
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to