If you want to list all letters, even if no names
for ($c=ord("A"); $c<=ord("Z"); $c++) {
$f = chr($c);
//select and list names begining with $f
}
otherwise
select name from table order by name
last_initial=""
while (...) {
$initial = substr($name,0,1);
if ($initial != $last_inital) echo "$initial ";
echo "$name<br>";
$last_initial = $initial;
}