Dave, you can absolutely nest cfoutputs if you use the group attribute.
This is a nice feature of Cold Fusion that allows reports to made
without a lot of logic involved.


Consider:

<cfset currentname="">
<cfoutput query="somequery">
        <cfif currentname neq name><hr>#name#<Br></cfif>
        #phonenumber#<br>
</cfoutput>


The same thing using nested cfoutputs:

<cfoutput query="somequery" group="name">
        #name#<br>
        <cfoutput>
                #phonenumber#<br>
        </cfoutput>
        <hr>
</cfoutput>

The first produces:

-------------------
Dave Bosky
843-444-4444
843-555-5555
-------------------
Matthew Small
843-111-1111
843-222-2222
843-333-3333
--------------------



The second produces: 
Without the top <hr>

Dave Bosky
843-444-4444
843-555-5555
-------------------
Matthew Small
843-111-1111
843-222-2222
843-333-3333
-------------------

If you have a properly designed query:

<cfquery name="somequery" datasource="dsource">
        select name, number
        from table
        order by name, number
</cfquery>

You get this returned set of data:

Dave Bosky              843-444-4444
Dave Bosky              843-555-5555
Matthew Small   843-111-1111
Matthew Small   843-222-2222
Matthew Small   843-333-3333

- Matt Small




-----Original Message-----
From: Bosky, Dave [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, March 07, 2002 1:28 PM
To: CF-Talk
Subject: RE: Group in cfoutput query. brain fart

Need to use cfloop you can't nest cfoutputs.

Dave
 
-----Original Message-----
From: Matthew R. Small [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, March 07, 2002 12:54 PM
To: CF-Talk
Subject: RE: Group in cfoutput query. brain fart

I'm not quite sure exaclt what you want but if you want to display the
name only once, then all of the phone numbers that are associated with
it, then you need multiple grouping values:


<CFOUTPUT QUERY="Employees" GROUP="city">    
        Office - Studio
        #Employees.City# - #Employees.StudioName#
        <cfoutput group="fullname">
                #Employees.LastName#, #Employees.FirstName# 
                <cfoutput>
                        #Employees.PhoneNumb# Edit Photo
                        ...
                </cfoutput>
        </cfoutput>
</cfoutput>




I think one of your problems is tha fact that firstname and lastname are
separate values.  Try combining them into a single field for sorting
purposes:

tblEmployee.Lastname & ' ' &  tblEmployee.Firstname as Fullname,

This works in access, I'm not quite sure about your db.

You need to also sort the records appropriately.  This step is not
required, but if you don't do it, then your output will not format
properly.

ORDER BY tblOffice.City, Fullname, tblEmployee.EMPLOYEE_ID;

I hope some of this helps.


- Matt Small




<cfquery name="Employees" datasource="RPH">
        SELECT  
                tblEmployee.Lastname & ' ' &  tblEmployee.Firstname as
Fullname, tblEmployee.FirstName, tblEmployee.EMPLOYEE_ID,
tblEmployee.LastName, tblEmployee.EmployeeID, tblEmployee.StudioID,
tblEmployee.Status, 
                tblStudio.StudioID, tblStudio.OfficeID,
tblStudio.StudioName, 
                tblOffice.OfficeID, tblOffice.City, 
                tblPhone.PhoneNumb, 
                tblFloor.floor 
                
        FROM tblEmployee, tblStudio, tblOffice, tblPhone, tblFloor 
        
        WHERE 
                tblEmployee.studioid = tblStudio.studioid AND 
                tblOffice.OfficeID = '#FORM.OfficeID#' AND 
                tblPhone.EmpResID = tblEmployee.EMPLOYEE_ID AND 
                tblEmployee.studioid in (#FORM.StudioID#) AND 
                tblEmployee.floorid = tblFloor.floorid 
        
        ORDER BY tblOffice.City, Fullname, tblEmployee.EMPLOYEE_ID;
</cfquery>
        
        Name
        Extension
        Edit

<CFOUTPUT QUERY="Employees" GROUP="city">    
        Office - Studio
        #Employees.City# - #Employees.StudioName#
        <cfoutput group="fullname">
                #Employees.LastName#, #Employees.FirstName# 
                <cfoutput>
                        #Employees.PhoneNumb# Edit Photo
                        <form action="Emp_Delete.cfm" method="post"
name="D_Emp"> <INPUT TYPE="checkbox" NAME="Status" VALUE="Yes" 
                        <cfif (# LSNumberFormat(Employees.Status) # EQ
1)>CHECKED</cfif>> <input type="hidden" name="EmployeeID"
value="#Employees.EmployeeID#"> <cfif #Employees.Status# EQ 0> <input
type="submit" value="check to hide user"> <cfelse><input type="submit"
value="un-check to show user"> </cfif></form>
                </cfoutput>

        </cfoutput>
</cfoutput>


______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to