function.php
function getCategories($id = null) {
$categoried = array();
$query = mysql_query("SELECT id,name FROM `categories`");
while ($row = mysql_fetch_assoc($query) ) {
$categories [] = $row;
}
dropdown.php
...
<select name="category">
<?php
foreach(getCategories() as $category){
?>
<option value=" <?php echo $category['id'];?> " > <?php echo $category['name'];?> </option>
<?php
}
?>
I am trying to use a drop down menu, but it seems like I can't figure out on how to populate the drop-down menu with items from mySql database. The code above doesn't fill my drop down menu. So can someone tell me where I have made the mistake