Re: Many variables. I want one array. How?

From: Date: Tue, 28 Nov 2000 21:16:10 +0000
Subject: Re: Many variables. I want one array. How?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27682@lists.php.net to get a copy of this message
Yeah... that's an "interesting" side effect... you might try with NAME="cb[1]" instead of "cb[]"... I'm not sure it will work... What I've done in similar cases is: <INPUT NAME="var_1"> <INPUT NAME="var_2"> ... <? $myvars = array(); reset( $HTTP_POST_VARS); while( list( $name, $value ) = each( $HTTP_POST_VARS )) { if( preg( "/^var_(\d+)$/", $name, $parts )) { $myvars[ (int) $parts[ 1 ] ] = $value; } } ?> ""Marko Perich"" <mperich@araucaniasur.cl> wrote in message news:000601c05984$4708fb60$1501a8c0@mpi.dssasur.cl... > > -----Mensaje original----- > De: Sebastian Delmont <sdelmont@loquesea.com> > Para: php-general@lists.php.net <php-general@lists.php.net> > Fecha: Martes, 28 de Noviembre de 2000 12:21 > Asunto: Re: [PHP] Many variables. I want one array. How? > > > >Name your HTML Form Variables as "cb[]"... > > > Oops. > > After trying with this, it seems that the first cb I check become cb[1], the > second cb[2], and so on, no matter in wich row it is. > > It is the correct way? > > Thanx. > > > > >""Marko Perich"" <mperich@araucaniasur.cl> wrote in message > >news:000101c0595f$074c9b00$1501a8c0@mpi.dssasur.cl... > >> Hello. > >> > >> My problem is that i am creating a form from a .php page and that page > can > >> have from 1 to many rows. In each row there is a checkbox named "cbX", > >where > >> X is the number of the row. > >> > >> I want the .php called from the previous submit to have access to the cbX > >> variables in an array (so i can work with it into a for loop). > >> > >> JavaScript does it automagically if I give the checkbox the same name > (say > >> just "cb"), but in php I don't know how. > >> > >> Any suggestion, clues, alternatives are gracefully accepted. > >> > >> Thanks. > >> > >> Marko. > >> > >> > >> -- > >> PHP General Mailing List (http://www.php.net/) > >> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > >> For additional commands, e-mail: php-general-help@lists.php.net > >> To contact the list administrators, e-mail: php-list-admin@lists.php.net > >> > > > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > >For additional commands, e-mail: php-general-help@lists.php.net > >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#27682) next »