Building on this: do something like 

<cfloop from="65" to="90" index="letter">
  <cfoutput>
    <cfif URL.where NEQ chr(letter) AND
listcontains(queryname.letterfield,letter)>
      <a href="list.cfm?where=#chr(letter)#">#chr(letter)#</a>
    <cfelseif not listcontains(queryname.letterfield,letter)>
      #(letter)#
    <cfelse>
      <b>#letter#</b>
    </cfif>
        </cfoutput>
</cfloop>

i.e. loop over all letters. If there's items starting with letter and we're
no on the page showing all items starting with that letter, show the letter
with a link. Otherwise, if there's no items starting with the letter, show
the letter without link. Otherwise, if we're on that letter page, show the
letter in boldface.

Still to implement: not just A-Z, but something like

0-9 A B C D E ... X Y Z.

Or, do the list from asc(min(upper(left(lastname,1)))) to
asc(max(upper(left(lastname,1)))) grouping on numbers/special signs.

Michel Vuijlsteke
Netpoint NV


> -----Original Message-----
> From: Russel Madere [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 26, 2001 5:50 PM
> To: CF-Talk
> Subject: RE: Alphabetic List
> 
> 
> I would start by coding it this way.
> 
> The select statement to create the letters would be:
> 
> SELECT DISTINCT upper(left(LastName, 1))
> FROM Name
> ORDER BY upper(left(LastName, 1))
> 
> Then I would look through the resulting query to create the 
> actual links.
> 
> The HREF for each letter would have a URL variable called 
> WHERE and it would
> be eaqual to the letter (i.e. ?WHERE=A)
> 
> The ALL Link would not have a WHERE URL variable
> 
> The page each link called would use the following logic:
> 
>       <cfif NOT isDefined("URL.WHERE)>
>               <CFQUERY....
>                       SELECT *
>                       FROM Name
>       <cfelse>
>               <CFQUERY...
>                       SELECT *
>                       FROM Name
>                       WHERE LastName LIKE '#URL.WHERE#%'
>       </cfif>
> 
> and display the names, etc.
> 
> Hope this helps.
> 
> Russel
> 
> 
> ============================================================
>   Russel Madere, Jr.         Senior Web Developer
>   ICQ: 5446158               http://www.TurboSquid.com
> 
> Some days you eat the bear; some days the bear eats you.
> ============================================================
> 
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, January 26, 2001 10:14
> > To: CF-Talk
> > Subject: Alphabetic List
> >
> >
> > Hi,
> >
> > In Yahoo address book, they have this list for finding a particular
> > person easily
> > by the first letter of their last name:
> >
> > All - 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 - Lists
> >
> > Does anyone have any insights on how the algorithm of 
> implementing this
> > feature?
> >
> > For example, I have a user database, and I want to use this 
> feature to
> > find
> > persons whose last name start with a particular letter.
> >
> > Thanks!
> >
> > Hong
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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