Hi Guys,
I have a list of areas in a DB and want to call these out to a Combo Box:
id | area
1 |Slough
2 |Burnham
Now I thought the below code would output these, but it does not
<?php
include("******");
function get_areas()
{
$query = 'SELECT *
FROM areas
ORDER BY area';
$result = @mysql_query($query);
if (!$result)
return false;
$num_areas = @mysql_num_rows($result);
if ($num_areas ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
?>
<select class="input" name="area" id="area">
<option value="" selected> </option>
<?php
$area_array = get_areas();
foreach ($area_array as $thisarea)
{
echo '<option value="';
echo $thisarea['area'];
echo '">';
echo $thisarea['area'];
echo '</option>';
}
?>
</select>
Can anyone please advise?
Thanks
Chris