|
Posted by skinnybloke on 10/13/97 11:24
Hi - I have the code below to display numbers and letters on a web
page. The script queries a database and selects the first character of
each company on there.
If the character exists on the database it creates a link for that
character, else it just displays the character.
This works fince except it is creating a link for number "0" yet there
are no company_name records beginning with "0". I currently only have
3 records on the database and all start with an alpha character yet
the script is showing the numeric 0 as a linkable field.
Does anybody know why this could be happening and how I could prevent
it?
<?php
// This section generates the numbers and letters for the company
search
$query = 'SELECT DISTINCT LEFT(company_name,1) FROM members';
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) $alphanums[] = $row[0];
for ($numbers = 0; $numbers <= 9; $numbers++) {
if(in_array($numbers, $alphanums)) {
echo "<a href='directory_new.php?coletter=$numbers'>$numbers </a>";
} else {
echo "$numbers ";
}}
echo '<br />';
for ($alphabet1 = A; $alphabet1 <= M; $alphabet1++) {
if(in_array($alphabet1, $alphanums)) {
echo "<a href='directory_new.php?coletter=$alphabet1'>$alphabet1
</a>";
} else {
echo "$alphabet1 ";
}}
for ($alphabet2 = N; $alphabet2 != AA; $alphabet2++) {
if(in_array($alphabet2, $alphanums)) {
echo "<a href='directory_new.php?coletter=$alphabet2'>$alphabet2
</a>";
} else {
echo "$alphabet2 ";
}}
?>
Navigation:
[Reply to this message]
|