Welcome Guest, Not a member yet? Register   Sign In
two dimensional array insert in codeigniter
#1

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

Attached Files Thumbnail(s)
   
Reply
#2

You could json encode and decode it then assign it to the data array
table column should be a text field.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

how to get those 2 values(regno,markid)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB