|
Posted by Charles on 09/07/06 17:54
I am trying the example of the book "Learning PHP5", here's an example
that doesn't work here. It's a simple array sent from a form, and I
want to display values sent, but if I select several meals from the
form, only the last one is displayed:
<form method="POST" action="eat.php">
<select name="lunch[ ]" multiple>
<option value="pork">BBQ Pork Bun</option>
<option value="chicken">Chicken Bun</option>
<option value="lotus">Lotus Seed Bun</option>
<option value="bean">Bean Paste Bun</option>
<option value="nest">Bird-Nest Bun</option>
</select>
<input type="submit" name="submit">
</form>
Selected buns:
<br/>
<?php
foreach ($_POST['lunch'] as $choice) {
print "You want a $choice bun. <br/>";
}
?>
On the book it says it should print all selected items. Here it
displays only the last one. I'm sure all are selected, because I hold
down the "Ctrl" key while selecting the options.
Any idea?
Thanks,
[Back to original message]
|