I am working on a project, where I am making an access based on the user group, but I have a problem when doing multiple insert. the question is how can I enter a value into the database from the checkbox with the insert replace
VIEW
<tr>
<td class='mail-select'>
<i class='fa fa-angle-right m-r-15 text-muted'></i>
<a href='email-read.html' class='email-name'>".$s->name."</a>
<input name='id_menu[]' value='".$s->id."' type='hidden'>
</td>
<td>
<div class='checkbox checkbox-primary m-r-15'>
<input name='read[]' value='Y' id='R-".$s->id."' type='checkbox'>
<label for='R-".$s->id."'></label>
</div>
</td>
<td>
<div class='checkbox checkbox-primary m-r-15'>
<input name='create[]' value='Y' id='C-".$s->id."' type='checkbox'>
<label for='C-".$s->id."'></label>
</div>
</td>
<td>
<div class='checkbox checkbox-primary m-r-15'>
<input name='update[]' value='Y' id='U-".$s->id."' type='checkbox'>
<label for='U-".$s->id."'></label>
</div>
</td>
<td>
<div class='checkbox checkbox-primary m-r-15'>
<input name='delete[]' value='Y' id='D-".$s->id."' type='checkbox'>
<label for='D-".$s->id."'></label>
</div>
</td>
</tr>
CONTROLLER
public function addRole()
{
$group = $this->input->post('group');
$num = $this->input->post('num');
$id_menu= $this->input->post('id_menu[]');
$read = $this->input->post('read[]');
$create = $this->input->post('create[]');
$update = $this->input->post('update[]');
$delete = $this->input->post('delete[]');
for ($i=0;$i<$num;$i++){
$data = array(
'group_id' => $group,
'menu_id' => $id_menu[$i],
'index' => $read[$i],
'add' => $create[$i],
'edit' => $update[$i],
'delete' => $delete[$i],
);
$role = $this->db->insert_batch('box_role', $data);
}
redirect("auth/role", 'refresh');
}
Aucun commentaire:
Enregistrer un commentaire