Re: Array of CheckBoxes
| From: | Morgan Grubb | Date: | Wed, 26 Jun 2002 02:45:58 +0000 |
| Subject: | Re: Array of CheckBoxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103889@lists.php.net to get a copy of this message | ||
Putting the square array brackets in the name field of the checkbox will
make it an array.
<input type="checkbox" name="array_of_checkboxes[]">
You can then rip through the created array using your preferred method
while(list($key, $value) = each($array_of_checkboxes))
/* do stuff */
}
or whatever floats your boat.
--
Cheers,
Morgan Grubb.
"César aracena" <icaam@icaam.com.ar> wrote in message
news:000e01c21cba$8ced6c60$5eed0dd1@gateway...
Hi all.
I have a form in which I must add a set of check boxes at the bottom.
Once the form is passed away, the information of the checked boxes
should be inserted into a DB. The thing is that I don't like to use
'tons' of "if" statements 'cause it will have way too many check boxes.
Is there any way of creating an Array which holds TRUE for check boxes
that where selected and NULL for the ones leaved clear? The final table
with the data stored should look like this:
+---------+-----------------+-----------+-----------+-----------+-------
-----+-----------+
| userid | date | option1 | option2 | option3 | option4 |
option5 |
+---------+-----------------+-----------+-----------+-----------+-------
-----+-----------+
| 1 | 2002-06-25 | true | true | false | false
| true |
| 2 | 2002-06-25 | false | true | true | false
| false |
| 2 | 2002-06-25 | true | false | false | true
| true |
+---------+-----------------+-----------+-----------+-----------+-------
-----+-----------+
Haw can this be achieved? If no can do, I will have to do if. else if.
else if. else if. and way too far down the page. else.
Thanks in advance,
<mailto:webmaster@icaam.com.ar> Cesar Aracena
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621