我是Codeigniter的新手,我想使用ajax在数据表中添加分页

时间:2019-06-27 04:52:30

标签: jquery mysql sql ajax codeigniter

当前我正在使用动态数据表引导程序4,我想在表中添加分页

查看:

<form role="form">
        <div class="card-body">
          <div class="row"> 

            <table id="example1" class="table table-bordered table-striped table-sm" >
                <thead>
                <tr>
                  <th>Bilty Id</th>
                  <th>LR No</th>
                  <th>Consignor Name</th>
                  <th>Consignor Gst No</th>
                </tr>

                </thead>
                <tbody>
                  <?php foreach($bilties as $bilty){?>
                <tr>
                  <td><?php echo $bilty->id;?></td>
                  <td><?php echo $bilty->lr_no;?></td>
                  <td><?php echo $bilty->consignor;?></td>
                  <td><?php echo $bilty->consignor_gst_no;?></td>
                  </tr>
                <?php }?>
                </tbody>
              </table>
        </div>
  </div>
</form>

控制器:

public function viewBilty(){
        $this->load->view('template/header');
        $this->load->view('template/sidebar');
        $data= array();

        $this->data['bilties'] = $this->biltyModel->viewBilty();

        $this->load->view('booking/bilty/viewbilty',$this->data);         
        $this->load->view('template/footer');
     }

型号:

public function viewEnableBilty($userid){
            $this->db->select('*');
            $this->db->from('bilty');
            $this->db->where('b.status', 'active');

            $query = $this->db->get();
            return $query->result();
         }

这是我的模型视图控制器,我有动态数据表,我想为此表添加分页

1 个答案:

答案 0 :(得分:1)

ADD脚本

https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css

<script>
    $(document).ready(function() {
        $('#example1').DataTable();
    } );
</script>

在您的html中