Here's how I'd do it
<?
$space = " ";
// create array of alphabet
for ($i = 65; $i < 91; $i++) {
$alphabet[($i - 65)] = chr($i);
}
// loop through results and display
foreach($alphabet as $value) {
if($value == "Z") {
echo "<a href=\"".$PHP_SELF."?ltr=".strtolower($value)."\">".$value."</a>";
} else {
echo "<a href=\"".$PHP_SELF."?ltr=".strtolower($value)."\">".$value."</a>".$space."|".$space;
}
}
if($_GET['ltr']) {
$query = mysql_query("SELECT * FROM table WHERE field_name LIKE '".$_GET["ltr"]."%'") or die(mysql_error());
// display results from query here
}
?>
It's dyanamic and it keeps you from having to have 26 different ifs with 26 different queries. The commented part that says create array of Alphabet also creates an array of the alphabet dynamically. You could always use
$alphabet = array("a","b","c","d", etc etc
But I didn't want to waste the time to do that. You should be able to work with this no problem and adapt it to your code.
Cgraz