Adding multiple checkboxes values to database

hi all

i m able to echo all the checkboxes selected through the below code


<input  type="checkbox" value="Battery"  name="checkbox[]" id="checkbox[]"
/>


for ($i=0; $i<count($_REQUEST['checkbox']);$i++) {
echo "chosen<br />$i. ".$_REQUEST['checkbox'][$i];
}

ouput is


0. battery
1. rocket
2. pineapple

but i want to insert all selected checkboxes values in database.

so what should i write in my query


$query = "insert into checkbox table (checkboxes) values()"

vineet

design your table so that each checkbox value is a separate row

hi r937

i have 30 checkboxes in my form.

so i have to make 30 rows or fields in my database.

is there any alternative

vineet

30 coumns or 30 rows if you want to use one value per column/row

other alternatives are multiple values in a single column (which violates first normal form) or a bitmap (which requires application code to interpret)

hi r937

yes i would like to insert all selected checkboxes values in one single column with a comma separator.

but that you say violates the form.

normally what is adapted by programmers.

i m new to it.

vineet

normally you would not store comma separated values. you would insert one new row for each value.