【问题标题】:Index limit in codeigniter paginationcodeigniter 分页中的索引限制
【发布时间】:2016-02-19 15:42:39
【问题描述】:

抱歉,我希望创建表分页连接两个表 我尝试创建它,当我单击“下一步”时,会出现这样的错误。

Error Index Limit

我在控制器中的代码

public function index()
{
    $this->load->model('mymodel');
    $this->load->library('pagination');
    $config['base_url'] = base_url().'index.php/admin/page/index/';
    $config['total_rows'] = $this->mymodel->tampil_data()->num_rows();
    $config['per_page'] = 10; 
    $this->pagination->initialize($config); 
    $data['paging']     =$this->pagination->create_links();
    $halaman            =  $this->uri->segment(3);
    $halaman            =$halaman==''?0:$halaman;
    $data['record']     =    $this->mymodel->tampil_data_paging($halaman,$config['per_page']);
    $this->template->load('template','view',$data);
}

和我的模型

    function tampil_data()
    {
        $query= "SELECT b.requestorname,b.checkin,b.checkout,b.company,b.email,b.contactnumber,b.purpose,
        kb.name,kb.checkinvisitor,kb.checkoutvisitor,kb.companyvisitor,kb.position,kb.contactnumbervisitor
                FROM messrequestor as b,messvisitor as kb
                WHERE b.idrequestor=kb.idrequestor";
        return $this->db->query($query);
    }

        function tampil_data_paging($halaman,$batas)
    {
        $query= "SELECT b.requestorname,b.checkin,b.checkout,b.company,b.email,b.contactnumber,b.purpose,
        kb.name,kb.checkinvisitor,kb.checkoutvisitor,kb.companyvisitor,kb.position,kb.contactnumbervisitor
                FROM messrequestor as b,messvisitor as kb
                WHERE b.idrequestor=kb.idrequestor limit $halaman,$batas";
        return $this->db->query($query);
    }

如何解决?

谢谢

【问题讨论】:

    标签: php mysql codeigniter pagination


    【解决方案1】:
    public function index()
    {
        $this->load->model('mymodel');
        $this->load->library('pagination');
        $config['base_url'] = base_url().'index.php/admin/page/index/';
        $config['total_rows'] = $this->mymodel->tampil_data()->num_rows();
        $config['per_page'] = 10; 
        $this->pagination->initialize($config); 
        $data['paging']     =$this->pagination->create_links();
        $halaman            =  $this->uri->segment(3);
        $halaman            =$halaman==''?0:$halaman;
        $data['record']     =    $this->mymodel->tampil_data_paging($halaman,$config['per_page']);
        $this->template->load('template','view',$data);
    }
    

    在此控制器中,您将段检索为“索引”,因此将其放置在您的 sql 中,您需要获取其他段

    【讨论】:

      【解决方案2】:
      $config['base_url'] = base_url().'index.php/admin/page/index/';
      //then you use this
      $halaman =  $this->uri->segment(3);
      $halaman =$halaman==''?0:$halaman;
      

      这是将段检索为“索引”,因此将其放置在您的 sql 中,这就是错误所在。如果实际值在之后,则您需要获取其他段,即 4

      $query= "SELECT b.requestorname,b.checkin,b.checkout,b.company,b.email,b.contactnumber,b.purpose,
          kb.name,kb.checkinvisitor,kb.checkoutvisitor,kb.companyvisitor,kb.position,kb.contactnumbervisitor
                  FROM messrequestor as b,messvisitor as kb
                  WHERE b.idrequestor=kb.idrequestor limit $halaman,$batas
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-21
        • 1970-01-01
        • 1970-01-01
        • 2013-06-13
        • 2017-06-22
        • 2013-05-22
        • 1970-01-01
        • 2018-04-23
        相关资源
        最近更新 更多