Re: Problem with array

From: Date: Tue, 30 Apr 2002 15:26:31 +0000
Subject: Re: Problem with array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-95384@lists.php.net to get a copy of this message
show the form..... ----- Original Message ----- From: Carlos Fernando Scheidecker Antunes <nando@antunes.eti.br> To: PHP-GENERAL <PHP-GENERAL@lists.php.net> Sent: Tuesday, April 30, 2002 10:11 AM Subject: [PHP] Problem with array Hello All, I've got a form that creates checkboxes based on the number of rows on a table. The user has to check some of the boxes and then click submit. The boxes are named RG1, RG2, RG3, .... If there are 4 checkboxes and the user selects them all or selects the first, second and fourth, or the first third and fourth my code works. But if the user selects the second, third and fourth (He does not checks the first one) no information is recorded on my array. Here's the code that I have to search the $HTTP_POST_VARS and then fill a array variable called $RG. function SearchRGs() { global $HTTP_POST_VARS; global $RGs; // fills the array variable RGs with the values of checked checkboxes that start with the name RG# (where # goes from 1,2,3,....). // returns the qty of checked RGs and size of the $RGs array. $index = count($HTTP_POST_VARS); $count = 0; for ($i=1; $i < $index; $i++) { if (isset($HTTP_POST_VARS["RG$i"])) { $RGs[] = $HTTP_POST_VARS["RG$i"]; $count++; } } return $count; } Can anyone help me with this? Why if I do not check the first checkbox on the form the array is not filled. Thank you, Carlos Fernando.

« previous php.general (#95384) next »