I would like to make a list of links at the top of a page containing the first letter of the members first name but only make the links appear if there is a particular member that has that last name.
I came up with this
$surname_query = "SELECT DISTINCT last_name FROM members ORDER BY last_name";
$getlist = mysql_query($surname_query) or die(mysql_error());
while ($row = mysql_fetch_array($getlist)) {
$surname = substr($row['last_name'], 0, 1);
echo "<a href='?lname=$surname' title='Surname´s beginning with $surname'>$surname</a> ";
}
Problem is it makes a seperate link for each surname it finds, so if there is a member with the surname Stewart and another with Sausages the code returns two links for the letter S.
Is there any way of making the query only return a letter once or any other way anyone can think of to do this?
Question
+unabatedshagie Subscriber¹
I have a list of members in my database.
I would like to make a list of links at the top of a page containing the first letter of the members first name but only make the links appear if there is a particular member that has that last name.
I came up with this
Problem is it makes a seperate link for each surname it finds, so if there is a member with the surname Stewart and another with Sausages the code returns two links for the letter S.
Is there any way of making the query only return a letter once or any other way anyone can think of to do this?
Link to comment
Share on other sites
8 answers to this question
Recommended Posts