0

I am workin on PHP codeigniter See this attached image, here i need to get values of selected checkboxes and save in a database table by clicking on the button called CONFIRM

My view Code:

<?php foreach($studentlist as $llist){
echo form_open("trusts/MoveData?id=".$llist['id']); }?>
<button name="submit" type="submit" value="<?php echo @$studentlist1->id; ?>" class="btn btn-success btn-flat pull-right marginBot10px"><i class="icon_set_1_icon-76"></i> CONFIRM </button>
<?php echo form_close(); ?>

<table class="table table-bordered" id="employee_grid">
    <thead>
        <tr>
        <!--<th><input type="checkbox" id="select_all"></th>-->
        <th>Select</th>
          <th>Student Name</th>
          <th>Gender</th>
          <th>Email</th>
          <th>Phone</th>
          <th>Program Id</th>
          <th>Program Name</th>

        </tr>
    </thead>
    <tbody>
        <?php 
        $i=1;
        foreach($studentlist as $llist){
        ?>
        <tr id="<?php echo $llist["id"]; ?>">

          <td><input type="checkbox" name="ids[]" value="<?php echo $llist['id']; ?>"> </td>
         <td><?php echo $llist['Name']; ?></td>
         <td><?php echo $llist['Gender']; ?></td>
          <td><?php echo $llist['Email']; ?></td>
          <td><?php echo $llist['Phone']; ?></td>
          <td><?php echo $llist['ProgramId']; ?></td>
          <td><?php echo $llist['ProgramName']; ?></td>

         <!-- <td></td>-->
          </tr>
        <?php 
            $i++;
        }
        ?>
    </tbody>
</table>

How get selected checkbox values of this view in my controller?

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Kishan
  • 13
  • 6
  • simpal using post it will give you array – Ahmed Ginani May 08 '17 at 06:04
  • Possible duplicate of [Get $\_POST from multiple checkboxes](http://stackoverflow.com/questions/4997252/get-post-from-multiple-checkboxes) – Spoody May 08 '17 at 06:04
  • when submit the form you can get data of selected ids by using this way- This will give you array of selected values $this->input->post('ids'); – Rajat Gupta May 08 '17 at 06:11
  • Please go through my code carefully. I don't have seperate checkboxes for each . I have one common Checkbox name as "ids" for all (table definition tags) – Kishan May 08 '17 at 06:55

1 Answers1

0

When the form is submitted you an get the selected checkbox values like:

$selected = $this->input->post('ids');

here $selected is an array, so use foreach() to get its values.

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
  • I tried this but it's not working. I m not able to link those selected ids to my CONFIRM(submit) button. As if now when i click on CONFIRM button it is fetching all the values of my view. But i need only selected id values to be fetched. – Kishan May 08 '17 at 06:40