Reply to Book example doesn't work here

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация