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!

Paging Grouped Results

Status
Not open for further replies.

neofactor

Technical User
Jul 30, 2000
194
US
Hey...

Well it has officially happened... I have gone insane. I wrote code over a year ago that answered my own question.. but now I forgot how to do it... and can't find the code!

What I need is... a simple paging through of a recordset that is using nested CFoutputs for a group.

If you understand what I said above... then you most likely have done the same thing.

Any help from the powers that be would be most apprciated.
Along with maybe a great script that handles this sort of thing so I dont have to go through this again.


<cfoutput query=&quot;qry_getnews&quot; group=&quot;PRESS_YEARS&quot;>
YEAR: #UCASE(PRESS_Years)#

<cfoutput group=&quot;PRESS_MONTHS&quot;>
#UCASE(MONTHASSTRING(PRESS_MONTHS))#

<cfoutput>
#PR_Title#
</cfoutput>

</cfoutput>

</cfoutput>

I think I remember adding in a counter inside the last cfoutput checking for the max to show. And another above the 1st output ## to prevent any trailing headers without results.

Thanks again...

David McIntosh

Have a nice day!
 
ok... I got it... easy...


I knew I was on the right track.

I just needed within each CFOUTPUT an if statement:

<CFIF qry_getnews.currentrow lt (r_start + r_max)>


This checks inside of the outputs.

Thanks anyways for readinbg this... It might help me again if I forget (again)

Thanks!

David McIntosh

Have a nice day!
 
Hi Dave,

I am working on one project, and now facing a problem.
I found these codes from somewhere in the net and applied them to my own application. Works great!


<cfquery name=&quot;GroupTest&quot; datasource=&quot;JoanTest&quot;>
SELECT EmpName,Year, Bonus
FROM Employee INNER JOIN PremiumPay ON Employee.EmpID = PremiumPay.EmpID
ORDER BY EmpName, Year
</cfquery>

<cfset BonusTotal = 0>
<cfset BonusCount = 0>
<cfoutput query=&quot;GroupTest&quot; GROUP=&quot;EmpName&quot;>
<cfset EmpBonusTotal = 0>
<cfset EmpBonusCount = 0>
<cfoutput>
<!--- print employee bonus --->
#EmpName#: #Year# #DollarFormat(Bonus)#<br>
<!--- increment employee statistics --->
<!--- NOTE: Bonus is never NULL --->
<cfset EmpBonusTotal = EmpBonusTotal + Bonus>
<cfset EmpBonusCount = EmpBonusCount + 1>
</cfoutput>
<!--- print employee statistics --->
Total Bonus: #DollarFormat(EmpBonusTotal)# and Average Bonus: #DollarFormat(EmpBonusTotal / EmpBonusCount)# <br><br>
<!--- increment grand totals --->
<cfset BonusTotal = BonusTotal + EmpBonusTotal>
<cfset BonusCount = BonusCount + EmpBonusCount>
</cfoutput>

<cfoutput>
ALL EMPLOYEES Bonus: #DollarFormat(BonusTotal)# and Average Bonus:#DollarFormat(BonusTotal / BonusCount)# <br><br>
</cfoutput>


The problem is when I add one group i.e. Department, I can never get it right. So now the output should be grouped by Department and EmpName.

Suggestion, please?
mansii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top