I have one task which two dimensional array of checkbox in db. In attached file shows clearly. that checkbox having values like 5001,5002,5003 each row accordingly. I want to insert that values accordingly to the corresponding regno values .
I want to insert the field like
insert into stud values(2010101001,5001);
insert into stud values(2010101001,5002);
insert into stud values(2010101001,5003);
insert into stud values(2010101002,5001);
insert into stud values(2010101002,5002);
insert into stud values(2010101002,5003);
only posted values to be insert
my view file like
<?php
$sno=1;
foreach($getstud as $row)
{
echo '<tr>'; ?>
<?php
echo '<td>'.$sno++.'</td>';
echo '<td>'.$row['regno'].'</td>';
echo '<td>'.$row['name'].'</td>';
?>
<?php ?>
<?php foreach($getsubc as $row1)
{?>
<td align="center"> <input type="checkbox" class="check" name="friend_id[]"
value="<?php echo $row1['markid'];?>" >
</td>
My controlle file
public function add_attend_studreg120(){
$friend_ids_array = $this->input->post('friend_id'); //name of the checkbox.
for($index=0; $index < count($friend_ids_array); $index++){
$data[$index]['user_id'] = $friend_ids_array[$index];
}
$this->User_model->saveMessage($data);
redirect(base_url().'studreg/');
}
this method working but only values insert but regno field not inserted. it shows blank. how to get the values. Its a data tables not a post item . how to get it