Final code looks like this (incase anyone's interested...

// Source to show first letters from database
$strSQL = "SELECT bandID, bandName FROM band ORDER BY bandName";
$result = mysql_query($strSQL,$db);
$numresults = mysql_num_rows($result);
// check records actually exist!
if($numresults != 0)
{
        //Set letter to null so that var exists but will still be displayed

        $letter = "";

        // Iterate through records
        for($i=0; $i < $numresults; $i++)
        {
                $row = mysql_fetch_array($result);
                // get first letter of band name
                if(substr($row["bandName"], 0, 1) != $letter)
                        {
                        $letter = substr($row["bandName"], 0, 1);
                        //print it with line breaks before and after for
nice formatting ;o)
                        echo "<br />$letter<br />";
                        }
                // Write the link to the band details
                echo "&nbsp;&nbsp;<a
href=\"viewband.php?bandID=$row[0]\">$row[1]</a><br />";
        }
}
else
{
// No records found, let them know!
echo "Sorry, there are no bands in the database at the moment.<br /> Please
try again later";
}
?>

>-----Original Message-----
>From: Macdonald-Wallace, Matthew J [mailto:s0209208@;glos.ac.uk]
>Sent: 23 October 2002 19:32
>To: [EMAIL PROTECTED]
>Subject: [wdvltalk] Re: [PHP] Looking for a hint, but not the whole so
>lution!
>
>
>>> A
>>> Abba
>>> ACDC
>>> Adams, Bryan
>>
>>two outta three of those bands are awful
>
>It was an example, I've been searchin OLGA for too long tonight...
>
>Cheers for the reply, seems much easier that way, I'll let you 
>know how I
>get on!
>
>Matt
>
>____ * The WDVL Discussion List from WDVL.COM * ____
>To Join wdvltalk, Send An Email To: 
mailto:wdvltalk-join@;lists.wdvl.com 
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%

____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:wdvltalk-join@;lists.wdvl.com 
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to