Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfoutput with cfloop...

Status
Not open for further replies.

fdgsogc

Vendor
Joined
Feb 26, 2004
Messages
160
Location
CA
I am trying to generate a unique code based on the number of records in two tables. I am using a cfloop within a cfoutput.
Here is my code.
Code:
<cfoutput query="getactivities">
<hr>
MainActivityID:#id#<br><br>
  <cfloop query="getaddresses">
  <cfset countertesta = countertesta +1>
  SubActivityID:#getactivities.id#&nbsp;
  CounterTestA:#countertesta#  <br>
  </cfloop>
</cfoutput>
This is giving me the following incorrect output.
Code:
MainActivityID:1

SubActivityID:1  CounterTestA:1 
SubActivityID:1  CounterTestA:2 

--------------------------------------------------------------------------------
MainActivityID:2

SubActivityID:1  CounterTestA:3 
SubActivityID:1  CounterTestA:4 

--------------------------------------------------------------------------------
MainActivityID:3

SubActivityID:1  CounterTestA:5 
SubActivityID:1  CounterTestA:6
The problem is that the SubActivity value should be the same as the MainActivity value.

Any ideas on how to correct this?
 
Code:
<cfoutput query="getactivities">
[red]<cfset countertesta = 0>[/red]
<hr>
MainActivityID:#id#<br><br>
  <cfloop query="getaddresses">
  <cfset countertesta = countertesta +1>
  SubActivityID:#getactivities.id#&nbsp;
  CounterTestA:#countertesta#  <br>
  </cfloop>
</cfoutput>



Hope This Helps!

ECAR
ECAR Technologies, LLC

"My work is a game, a very serious game." - M.C. Escher
 
Here is another thread ecar and i answered about looping nested queries.

thread232-1045543

Beware of programmers who carry screwdrivers.
 
Thanks.

I decided not to include the ActivityID in the output since the counter is creating a unique code.

That's really all I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top