Re: pg_exec
| From: | php3 at developersdesk dot com | Date: | Sat, 03 Mar 2001 03:39:08 +0000 |
| Subject: | Re: pg_exec | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-7092@lists.php.net to get a copy of this message | ||
Addressed to: "dime" <dime@gulfsales.com>
php-db@lists.php.net
** Reply to note from "dime" <dime@gulfsales.com> 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
http://www.developersdesk.com