Reply to Re: Printing array items sent in a form

Your name:

Reply:


Posted by ED on 02/02/07 15:12

"Charles" <landemaine@gmail.com> wrote in message
news:1170427958.915021.200480@p10g2000cwp.googlegroups.com...
> I'm trying an example from the book "Learning PHP5" but it doesn't
> work as Expected. Snippet:
>
> <form method="POST" action="index.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/>";
> }
> ?>
>
>
> 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,
>

hi Charles,
looks like you have space characters in the select name (between the square
brackets),
try: <select name="lunch[]" multiple>
and not: <select name="lunch[ ]" multiple>

cheers,
ED

[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

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