简体   繁体   English

如何获取多个选定的复选框值

[英]How to get multiple selected checkbox values

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 我正在使用PHP Codeigniter, 请参见此图像,在这里,我需要获取选定复选框的值,并通过单击名为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? 如何在控制器中获取此视图的选定复选框值?

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. 这里$selected是一个数组,因此请使用foreach()获取其值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM