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?
They've told outlets who got review units that it isn't. Partially because they believe that contributes to closed ecosystems. GamersNexus also believes this is because Valve's fighting a monopolistic practices lawsuit in Europe right now. They've also never subsidized any of their past hardware efforts and well, they definitely aren't subsidizing the Steam Deck right now.
(macOS) Screen zoom was broken for me in beta 1 and it's now working properly in beta 2. In terms of performance and UI design/consistency, these betas are already much better than Tahoe.
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
$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?
Link to comment
https://www.neowin.net/forum/topic/618171-sql-get-first-letter-of-a-result/Share on other sites
8 answers to this question
Recommended Posts