0

controller

class Category extends Admin_Controller {
    public function __construct() {
            parent::__construct();
            $this->load->model('category_model');
        }
    public function index(){
        $data['select'] = $this->category_model->getinfo();
        $this->load->view('category_view', $data);
    }
  }
?>

model

function getinfo(){
        $query = $this->db->get('user');
        return $query;
}

view

<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
   </head>
   <table border="1">
      <tbody>
         <tr>
            <td>Id</td>
            <td>Name</td>
             <td>lastname</td>
         </tr>
         <?php
         foreach ($select->result() as $row)
         {
            ?><tr>
            <td><?php echo $row->id;?></td>
            <td><?php echo $row->name;?></td>
            <td><?php echo $row->lastname;?></td>

            </tr>
         <?php }
         ?>
      </tbody>
   </table>
<body>
</body>
</html>

i need to place multiple checkboxes so i can delete data via clicking it i also must have to check multiple checkbox at once(single check and check All both).

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Pranav Shah
  • 89
  • 11

1 Answers1

1
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Untitled Document</title>
</head>
<body>
 <table border="1">
  <tbody>
     <tr>
        <td>Id</td>
        <td>Name</td>
         <td>lastname</td>
         <td>*</td>
     </tr>
     <?php
     foreach ($select->result() as $row)
     {
        ?><tr>
        <td><?php echo $row->id;?></td>
        <td><?php echo $row->name;?></td>
        <td><?php echo $row->lastname;?></td>
        <td><?php echo form_checkbox('action[]', $row->id); ?></td>
        </tr>
     <?php }
     ?>
  </tbody>
 </table>
 </body>
</html>

When you post this you will get array of id on which action need to be performed.

Gopakumar Gopalan
  • 1,187
  • 14
  • 22