I'm not sure what any of the posted sample code is really trying to get at
... but from what I gather you want:

a)  Links at the top of the page, allowing somebody to jump to the
beginning of the section of people's who's last name begins with that
letter.

b)  The names all come from the database, ordered by last name.

So, you end up with something like this:

<?php
        // Warning:  I haven't tested, debugged, or even ran this
        // through a syntax checker.  It's completely off the cuff.

        for($c = 'A'; $c <= 'Z'; $c++) {
                // This works in C... I assume PHP acts similar.
                echo "<a href=\"$PHP_SELF#$c\">$c</a>\n";
        }

        $recordset = ... however you query your particular DB.

        $curr_letter = '';
        $row = array_shift($recordset);
        while ($row != NULL) {
                // Making assumptions on DB fields here.
                $lname = $row->last_name;
                if (substr($lname, 0, 1) != $curr_letter) {
                        $curr_letter = substr($lname, 0, 1);
                        echo "<a name=\"$curr_letter\">\n";
                }
                // Print the user info now
                $row = array_shift($recordset);
        }
?>

If you want to get fancy you could query the recordset first, then iterate
through the alphabet and for each letter scan ahead in the recordset
looking for somebody w/ a last name beginning with that letter.  If none
found, print out a grey non-linked letter, and continue to the next one.
It'd be slower... but act a lot nicer.

If you're sure you'll have a last name for every letter in the alphabet...
just use something like I posted.

Hope that helps,

Justin Buist
Trident Technology, Inc.
4700 60th St. SW, Suite 102
Grand Rapids, MI  49512
Ph. 616.554.2700
Fx. 616.554.3331
Mo. 616.291.2612

On Wed, 22 Aug 2001, Rick Emery wrote:

> The NAME indicator (#), must precede the data separator (?).
>
> I think what you want is:
> <a href=\"/members/members.php?$memltr=$memb\">$member</a>
>
> To use the NAME indicator, your line would read:  <a
> href=\"/members/members.php#$memb?$memltr\">$member</a>
> which I doubt is what you want.
>
> Richard Emery
>
> -----Original Message-----
> From: Howard Picken [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 22, 2001 3:50 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] using <A NAME> ref
>
>
> Hi
>
> I'm trying to use the A NAME tag on a php4 generated page.
>
> The pages being generated are alphabetically list
> (e.g. Page just lists people with surname starting with A)
>
> <a href=\"/members/members.php?$memltr#$memb\">$member</a>
>
> It doesn't work of course. Anyone have any ideas?
>
> Howard Picken
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP Database Mailing List (http://www.php.net/)
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