-----snip-------
So I'm almost almost there, but now when I click the # it shows me all records,
is my foreach range not right?
//Create array with letters AND number sign
$letters = range('A','Z'); array_push($letters, '#');
$menu = '';
$selectedLetter = isset($_GET['letter']) ? $_GET['letter'] : null;
foreach($letters as $letter) { $menu .=
($letter == $selectedLetter) ? sprintf('%s ',
$letter) : sprintf('<a
href="browse.php?letter=%s">%s</a> ', $letter, $letter);
} echo "<div align=\"center\"><b>{$menu}</b><br /></div>";
//Show all restaurants that start with $letter not between "A" and "Z"
$other = ctype_digit($letter);
foreach(range('0','9') as
$other) $sql = "SELECT
DISTINCT ID, name, address FROM restaurants WHERE name LIKE '{$other}%' ";
$result = mysql_query($sql)
or die(mysql_error());
while($row =
mysql_fetch_assoc($result)){
$name = $row['name'];
printf(
'<a
href="view.php?ID=%s"><b>%s</b><br />%s<br /><br /></a>',
$row['ID'],
$row['name'],
$row['address']
);
}
//Show all restaurants that
start with $letter $sql
= "SELECT DISTINCT ID, name, address FROM restaurants WHERE name LIKE
'{$selectedLetter}%'";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$name =
$row['name'];
printf(
'<a href="view.php?ID=%s"><b>%s</b><br />%s<br /><br /></a>',
$row['ID'],
$row['name'],
$row['address']
);
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php