Addressed to: "dime" <[EMAIL PROTECTED]>
              [EMAIL PROTECTED]

** Reply to note from "dime" <[EMAIL PROTECTED]> Fri, 2 Mar 2001 17:51:55 -0600
> ------=_NextPart_000_001D_01C0A341.7820EF80
> Content-Type: text/plain;
>       charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> I have been wondering this for a while and finally have the chance to =
> ask.  What I'm trying to do is select a bunch of names from one table in =
> a postgresql database. The way I'd like to display them is =
> alphabetically and indexed by the first letter.  So they look similar to =
> this:
> A
> Alexandria, Mark
> Angel, Chris
> B
> Boy, John
> C

I don't know pgsql, but this is a PHP question.  Here is how I would do
it in MySQL, you should be able to change it to pgsql pretty easy.

$FirstChar = '';
while( list( $Name, $Field2, $Fieldn...) = mysql_fetch_row( $Result )) {
   #  Feel free to substitute your favorite way to return data
   #  from pgsql in the line above...

   if( $FirstChar != $Name{0} ) {
      echo $Name{0}, "<BR>\n";
      $FirstChar = $Name{0};

   echo $Name, "<BR>\n";

Rick Widmer
Internet Marketing Specialists

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to