EDIT: THANKS - I MANAGED IT IN THE END
SHOULD HAVE TRIED FOR LONGER BEFORE POSTING
SORRY
how do you populate a drop down html box within a form, but populate it with values from a php array
for example
<form name="mname" action="index.php" method="post">
<select name='values'>
<option> </option>
<option> </option>
</form>
i can do it by echoing it out, thus not needing the form, but i really need to get at the value i am echoing in th开发者_如何学Goe drop down box later, so was hoping someone could show me how it can be done like this, using php
<?php
foreach ($myArray as $value) {
$checked = ($_GET['values'] == $value) ? " checked" : "";
$saveValue = htmlspecialchars($value);
print "<option$checked>$safeValue</option>";
}
?>
精彩评论