PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > multiple select in a form
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
multiple select in a form

Réponse
 
LinkBack Outils de la discussion
Vieux 12/06/2007, 16h39   #1 (permalink)
Michel Simeon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut multiple select in a form

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?ports...ts=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 me and tell me how to get at the full data sent by the
form ?

MS
  Réponse avec citation
Vieux 12/06/2007, 16h54   #2 (permalink)
iktorn
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: multiple select in a form

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?ports...ts=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 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
  Réponse avec citation
Vieux 12/06/2007, 18h26   #3 (permalink)
Michel Simeon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: multiple select in a form

iktorn wrote:
> 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?ports...ts=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 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"
>

That was it, many thanks

MS
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h31.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08351 seconds with 11 queries