Hello
I am trying to run a query that produces a drop down list from an array. The array has values stored like this:
pencil, ruler
ruler, protractor
pencil, ruler, compass
etc
I want to split the array then only return distinct values. So the above would be a drop down containing pencil, ruler, protractor and compass. Can anyone help me out with this please? Here's my code at the moment, but I'm not exploding the array and I'm not sure how to in this context.
<?php
$query = "SELECT DISTINCT category FROM table";
$result = @mysql_query ($query);
$pulldown = '<option value="Any">Any</option>';
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
$pulldown .= "<option value=\"{$row['category']}\">{$row['category']}</option>\n";
}
?>
<select class="formbit" name="category">
<?php echo $pulldown; ?>
</select>
Many thanks!