Re: HTML Checkboxes and PHP variables

From: Date: Wed, 29 May 2002 14:13:15 +0000
Subject: Re: HTML Checkboxes and PHP variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99742@lists.php.net to get a copy of this message
What version of PHP are you using? Is register_globals on or off? Try $_GET['foo'] as the array name, instead of $foo, or $_POST['foo'], depending on the method of your form. ---John Holmes... ----- Original Message ----- From: "Michael Hall" <olc@ninti.com> To: "1LT John W. Holmes" <holmes072000@charter.net> Cc: <php-general@lists.php.net>; "Brad Harriger" <bradharriger@clarionhospital.org> Sent: Wednesday, May 29, 2002 7:39 PM Subject: Re: [PHP] HTML Checkboxes and PHP variables > > I've been wrestling with the same issue. I had some code loop through and > create an arbitrary number of checkbox inputs with the name 'foo[]' > > I then attempted to access the array using: > > foreach ($foo as $bar) > { > echo $bar; > } > > but I got error messages telling me that $foo is not an array :-( > > I'm using Netscape 4.7 something on Red Hat 6.2 ... could this be an > issue? I know Netscape can be pretty buggy and fussy at the best of times. > > Michael > > > On Wed, 29 May 2002, 1LT John W. Holmes wrote: > > > If you name the form elements as arrays, then yeah, they are pretty much the > > same. > > > > <input type=checkbox name=foo[] value=one>One > > <input type=checkbox name=foo[] value=two>Two > > <input type=checkbox name=foo[] value=three>Three > > > > When submitted, $foo will be an array containing the values that were > > checked. If a box was not checked, it won't have any value in the array. > > > > i.e. If you check One and Three, then you'll have a $foo array like this: > > > > $foo[0]='one'; > > $foo[1]='three'; > > > > ---John Holmes... > > > > ----- Original Message ----- > > From: "Brad Harriger" <bradharriger@clarionhospital.org> > > To: <php-general@lists.php.net> > > Sent: Wednesday, May 29, 2002 8:56 AM > > Subject: [PHP] HTML Checkboxes and PHP variables > > > > > > > Are HTML Checkbox values handled the same way as Select Multiple tags? > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > -- > -------------------------------- > n i n t i . c o m > php-python-perl-mysql-postgresql > -------------------------------- > Michael Hall ninti@ninti.com > -------------------------------- > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#99742) next »