that's a little extreme (26 queries).

try something like this:

------------------------------------------------------------------
<CFQUERY NAME="get_names" DATASOURCE="(your DSN)">
        SELECT
                firstname,
                lastname
        FROM
                yourtable
        ORDER BY
                lastname ASC
</CFQUERY>

<CFSET rem_letter= "">
<CFSET first_letter = "a">

<CFOUTPUT QUERY="get_names">
        <CFIF #first_letter# IS NOT #rem_letter#>
                <BR>
                #Ucase(Left(lastname, 1))#
                <BR>
        </CFIF>
        #lastname#, #firstname#
        <BR>
        <CFSET rem_letter = #Left(lastname, 1)#>
</CFOUTPUT>
------------------------------------------------------------------

-----Original Message-----
From: Bruce, Rodney [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 12, 2001 10:44 AM
To: CF-Talk
Subject: RE: <cfoutput> lists Alphabetically


this is one way.


<CFLOOP index="letter"
list="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" delimiters=",">
        <CFQUERY name="list" datasource="database" dbtype="ODBC">
                SELECT table.fname, table.lname
                FROM table
                WHERE table.name Like '#letter#%'
                ORDER BY table.name;
        </CFQUERY>

        <CFOUTPUT>#letter#</CFOUTPUT>
        <CFOUTPUT Query="list">
        #list.lname#, #list.fname#
        </CFOUTPUT>
</CFLOOP>

-----Original Message-----
From: Christine Kelley [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 12, 2001 10:28 AM
To: CF-Talk
Subject: <cfoutput> lists Alphabetically



Hi!
   How do I output a whole list of names from a query
grouped alphabetically?  Output example:

A
Allen, Bob
Ames, John

B
Book, Sam
Briant, Max

I'm thinking it's by somehow using the group attribute of
the <cfoutput> tag or looping through the query, but I'm
not sure exactly how to get these results.

Thank-you for any help!
   Christine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to