Forum Moderators: coopster
Here's the code...
if (!isset($_GET['letter'])) {$letter = "A";} else {$letter = $_GET['letter'];}
echo '<div align="center"><b>';
for ($i=65; $i<90; $i++) {
if ($letter!= chr($i)) {echo '<a href="index.php?letter='.chr($i).'">';}
echo chr($i)." ";
if ($letter!= chr($i)) {echo '</a>';}
}
echo "</b></div><p>";
$query="SELECT * FROM songs WHERE artist LIKE '".$letter."%'";
So I just want to add one link before A B C.... for everything that isn't a letter
Thanks in advance :)
You can use either the MySQL function ASCII or SUBSTRING to do this. So to fetch all artists whose name doesn't start with an alpha character:
$query="SELECT * FROM songs WHERE ASCII(UPPER(artist)) NOT BETWEEN ASCII('A') and ASCII('Z')";
or
$query="SELECT * FROM songs WHERE UPPER(SUBSTRING(artist,1,1)) NOT BETWEEN 'A' and 'Z'";
Hope this helps.