Apologies for any lack of description as this is my first post on this forum.
I'm currently designing a website for a golf society and need to list all the members of that golf society sorting them alphabetically, i also want the list to have alphabetical dividers. For example a header saying 'A' containing all of the members who's last name starts with the letter 'A' and so on. Obviously if there is no member with a certain letter last name the header will not be shown.
The current code i am working with is shown below:
<?php $get_members = mysql_query("SELECT * FROM members"); $result = mysql_fetch_array($get_members); $initial = ''; foreach($result as $name) { if($name[0] != $initial) { $initial = $name[0]; echo "<div class=\"item_header\">"; echo "<p>$initial</p>"; echo "</div>"; } echo "$name"; } ?>
I am aware that somewhere within this code i need to specify the last_name but wherever i put it i get errors thrown back at me.
This code may be completely wrong but if you could shed any light on the matter that would be greatly appreciated.
Thanks in advance
Dan
Attached Files
-
Screen_shot_2010_02_25_at_12.20.36.png (38.85KB)
downloads: 5