I'm working on web app using codeigniter framework and setting privileges for different type of users so I need to add approximately 35 rows in db for each user and each row have 6 checkbox values (0,1). I'm having difficulty while storing these values in array and sending to MODEL for insertion.
Here is Controller code:
public function set_priv(){
$data = array(
array(
'type_id' => $this->input->post('priv_type_id'),
'module_name' => 'Classes',
'can_access' => $this->input->post('classes[0]'),
'can_insert' => $this->input->post('classes[1]'),
'can_delete' => $this->input->post('classes[2]'),
'can_update' => $this->input->post('classes[3]'),
'can_export' => $this->input->post('classes[4]'),
'can_print' => $this->input->post('classes[5]'),
),
// ),
);
}
HTML Form Code for understanding Each check box for access, insert, update and delete privilege etc.
<div class="col-md-1">
<input type="checkbox" name="classes[]" />
</div>
<div class="col-md-1">
<input type="checkbox" name="classes[]" />
</div>
<div class="col-md-1">
<input type="checkbox" name="classes[]" />
</div>
<div class="col-md-1">
<input type="checkbox" name="classes[]" />
</div>
<div class="col-md-1">
<input type="checkbox" name="classes[]" />
</div>
<div class="col-md-1">
<input type="checkbox" name="classes[]"/>
</div>