Re: Re: ordered alpabeticaly list

From: Date: Thu, 13 Dec 2001 18:35:59 +0000
Subject: Re: Re: ordered alpabeticaly list
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77639@lists.php.net to get a copy of this message
Thnk's Mike, But what I really need is create a separation like this ex: A ab... ac.. ad.. B be... bee... .. for all the names in my table Thank's again Rodrigo on 12/13/01 4:30 PM, Mike Eheler at meheler@idearesource.com wrote: > If I understand you correctly, you want to put a separator when the > letter changes. > > Try this: > > $result = mysql_query('select name from people order by name'); > $lastletter = ''; > while ($data = mysql_fetch_array($result)) { > $curletter = strtolower(substr($data['name'],0,1)); > if ($curletter != $lastletter) { > // Put code to insert a separator here > } > // put code to display the name here > $lastletter = $curletter; > } > > Mike > > Rodrigo Peres wrote: > >> Hi list, >> >> I have a mysql tables, with names on it. I'd like to select this names >> ordered by name and output it to a html in alphabetical order, but separates >> by letter, ex: a, names with a, b.... >> I've done the select, but I can't figure out how to output the respective >> letters separated. >> >> >> Thank's in advance >> >> Rodrigo Peres >> >> > --

« previous php.general (#77639) next »