duanpi2033 2015-11-18 02:51
浏览 46
已采纳

codeigniter分页中的索引限制

Sorry, i want the create table pagination to join two tables i've try to created it and when i click 'next' there's error like this.

Error Index Limit

My Code in controller

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);
}

and mymodel

    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);
    }

how to solve it?

Thank You

  • 写回答

2条回答 默认 最新

  • dpz7935 2016-02-28 14:35
    关注
    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);
    }
    

    in this controller you retrieving the segment as 'index' so this is being placed in your sql, you need to get other segment

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?