For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > June 2007 > multiple select in a form









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author multiple select in a form
Michel Simeon

2007-06-12, 9:59 pm

I am running a PHp script to produce an HTML form with a SELECT MULTIPLE
feature.

When I set method = GET and click on the SUBMIT button, the URL of the
call page is:
http://localhost/test/this.php?port...rts=Po&ports=La

which tells me that the four options i selected are indeed being sent.

But when I try to get at the daata, I have a problem. A dump of the
$_GET variable only gives me the last of the four values:
array(1) { ["ports"]=> string(2) "La" }

I added the following in my script:
foreach ($_GET['ports'] as $p)echo $p . "<br>";

All I got was: Warning: Invalid argument supplied for foreach() in ...

Can somebody help me and tell me how to get at the full data sent by the
form ?

MS
iktorn

2007-06-12, 9:59 pm

Michel Simeon napisał(a):
> I am running a PHp script to produce an HTML form with a SELECT MULTIPLE
> feature.
>
> When I set method = GET and click on the SUBMIT button, the URL of the
> call page is:
> http://localhost/test/this.php?port...rts=Po&ports=La
>
> which tells me that the four options i selected are indeed being sent.
>
> But when I try to get at the daata, I have a problem. A dump of the
> $_GET variable only gives me the last of the four values:
> array(1) { ["ports"]=> string(2) "La" }
>
> I added the following in my script:
> foreach ($_GET['ports'] as $p)echo $p . "<br>";
>
> All I got was: Warning: Invalid argument supplied for foreach() in ...
>
> Can somebody help me and tell me how to get at the full data sent by the
> form ?
>
> MS


The problem is that in input tags you should use name="foo[]" instead of
name="foo"

--
Wiktor Walc
http://phpfreelancer.net
Michel Simeon

2007-06-12, 9:59 pm

iktorn wrote:
> Michel Simeon napisał(a):
>
> The problem is that in input tags you should use name="foo[]" instead of
> name="foo"
>

That was it, many thanks

MS
Threeway

2007-06-13, 2:49 am

Alyson Hannigan and Ashlee Simpson Have Fun In Sauna!
http://www.WatchingTheTube.com/Player.php?watch=1673286
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com