Im trying to learn how to make a drop down menu and in my PHP book i was given this code
<?php
function generate_menu($name, $options, $default="") {
$html = "<SELECT NAME=\"$name\">";
foreach($options as $value => $label) {
$html .= "<OPTION ";
if ($value == $default)
$html .= "SELECTED ";
$html .= "VALUE =\"$value\">$label</OPTION>";
}
$html .= "</SELECT>";
return($html);
}
?>
Now when i run this script i have a blank screen.
But when i add to the bottom
echo generate_menu($name, $options, $default="");
I get the Drop down menu produced but i also have an error saying
Warning: Invalid argument supplied for foreach() in C:\wamp\www\Scripts\dd_menu.php on line 5
Could sombody please tell me what is going wrong.
And also could someone explain what the script does becuase im new to PHP So i dont know.
Thanks
