I'm trying an example from the book "Learning PHP5" but it doesn't
work as Expected. Snippet:
<form method="POST" action="index.p hp">
<select name="lunch[ ]" multiple>
<option value="pork">BB Q Pork Bun</option>
<option value="chicken" >Chicken Bun</option>
<option value="lotus">L otus Seed Bun</option>
<option value="bean">Be an Paste Bun</option>
<option value="nest">Bi rd-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/>";
}
?>
When I select several itens with the Ctrl key, it still prints the
last item only, ie: "You want a nest bun."
I double-checked, and I selected several items. Any idea?
Thanks,
work as Expected. Snippet:
<form method="POST" action="index.p hp">
<select name="lunch[ ]" multiple>
<option value="pork">BB Q Pork Bun</option>
<option value="chicken" >Chicken Bun</option>
<option value="lotus">L otus Seed Bun</option>
<option value="bean">Be an Paste Bun</option>
<option value="nest">Bi rd-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/>";
}
?>
When I select several itens with the Ctrl key, it still prints the
last item only, ie: "You want a nest bun."
I double-checked, and I selected several items. Any idea?
Thanks,
Comment