Re: multiple checkbox/select problem

From: Date: Thu, 20 Jul 2000 22:27:29 +0000
Subject: Re: multiple checkbox/select problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7488@lists.php.net to get a copy of this message
Hi Patrick, You're on the right track. $eventdate returns "Array". $eventdate[0] will return the first letter of that, which is "A". What's happened is that $HTTP_GET/POST_VARS is an array and $eventdate is an array within that array. Here is some contrived code that shows mulitple checkboxes with the same name and one with a unique name. The php at the top walks through the returned array(s). <? if( $HTTP_GET_VARS ) { reset( $HTTP_GET_VARS ); while( $key = key( $HTTP_GET_VARS ) ) { if( is_array( $HTTP_GET_VARS[ $key ] ) ) { $num = count( $HTTP_GET_VARS[ $key ] ); for( $i=0; $i<$num; $i++ ) { echo "$$key" . "[ $i ] = " . $HTTP_GET_VARS[ $key ][ $i ] . "<br>\n"; } } else { print "$key = " . $HTTP_GET_VARS[ $key ] . "<br>\n"; } next( $HTTP_GET_VARS ); } } ?> <form name="test100" action="test100.php" method="get"> <? for( $i=0; $i<10; $i++ ){ ?> <input type="checkbox" name="Groupie[]" value="<?=$i?>">Groupie <?=$i?><br> <? } ?> <br> <input type="checkbox" name="Loner" value="ImChecked">Loner<br> <input type="submit"> </form>  Hope that was helpful, mike w. Patrick Reagan wrote: > > i have a date selection form for a user to check multiple dates an even > occurs. I have searched the web, looked at the php manual to no avail, > so i am posting it here. > > i have a series of checkboxes like this > <input type="checkbox" name="eventdate" value="7/20/2000"> > > and there are about 60 on the same page w/ the same name and different > values. > > i try getting the value by doing <? print $eventdate; ?> and it gives me > just the last one selected. > > fine, i changed the checkbox code to: > <input type="checkbox" name="eventdate[]" > value="7/20/2000"> (added the > [] after the name) > as per some documentation i had read > > now a <? print $eventdate; ?> returns a single string: "Array" > so I try <? print $eventdate[0]; ?> to hopefully get the first date. > instead, i get "A" > > weird. > this is the same for both checkboxes and multiple select. > > i am using PHP 4.0.0 on Linux 2.2.14 > any help is greatly appreciated. > > -- > 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 (#7488) next »