Hi all -
I would like to generate a list of links from a-z based on the records returned from a query (for example, records are returned for A, B and F so they have links, C, D and E do not have a record and are not linked:
<a href="#">A</a> <a href="#">B</a> C D E <a href="#">F</a>)
I have tried using:
PHP Code:
public function getCarrierByAlphabet() {
$alphabet = range('A', 'Z');
foreach ($alphabet AS $alpha) {
$getCarrierByAlphabetQuery = mysql_query("SELECT carrierName FROM carriers WHERE carrierName LIKE '$alpha%' ORDER BY carrierName") or die ('Get Carrier By Alphabet Query Error --- MySQL Error No: '.mysql_errno().' --- '.mysql_error());
$alphaCount = mysql_num_rows($getCarrierByAlphabetQuery);
$alphaLinks = ($alphaCount > 0 ? '<a href="'.WEBSITE_URL.'/viewCarriers.php?alpha='.$alpha.'">'.$alpha.'</a>' : $alpha);
echo $alphaLinks;
}
return $alphaLinks;
}
this list that echos displays and works, but the values returned displays only Z
am I supposed to have a foreach on the page this is displaying on?