用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1475|回复: 3
收起左侧

[已解决] 分页的问题

[复制链接]
发表于 2015-2-25 14:57:35 | 显示全部楼层 |阅读模式
分页函数为什么会失控!

这个是成功的


class news extends CI_Controller{
        function __construct(){
                parent::__construct();
        }
       
        function trys(){
     $this->load->library('pagination');
     $this->load->helpers('url');
     $config['base_url'] = site_url('news/trys');
     $config['total_rows'] = 200;
     $config['per_page'] = 20;
     $this->pagination->initialize($config);
         $offset = intval($this->uri->segment(3));
         echo $offset;

     $data['links']  = $this->pagination->create_links();
         $this->load->view('new',$data);
         
         
         }
}




这个是失败的
function show(){       
                $this->load->library('pagination');
     $this->load->helpers('url');
     $config['base_url'] = site_url('admin/absent_info/show');
     $config['total_rows'] = 200;
     $config['per_page'] = 20;
     $this->pagination->initialize($config);
         $offset = intval($this->uri->segment(4));
         echo $offset;

     $data['link']  = $this->pagination->create_links();
         $this->load->view('admin/sort6_1',$data);
       
               
        }
        我只是路由的层数多了一层为什么他的下一页就下不去了,默认的永远都是第一页。怎么点击其他的页,都是第一


发表于 2015-2-25 15:10:30 | 显示全部楼层
分頁類...我看了很多說不好用
自己取 GET 值去判斷可能省事的多
 楼主| 发表于 2015-2-25 16:13:42 | 显示全部楼层
Closer 发表于 2015-2-25 15:10
分頁類...我看了很多說不好用
自己取 GET 值去判斷可能省事的多

我试了一下$config['uri_segment'] = 4;加上这个就可以了。我跟别人讨论得来的

发表于 2015-6-2 10:49:55 | 显示全部楼层
luofuchuan 发表于 2015-2-25 16:13
我试了一下$config['uri_segment'] = 4;加上这个就可以了。我跟别人讨论得来的

...

因为ci默认的$config['uri_segment'] = 3,而在你的URL中,3对应的是show,所以就失控了

本版积分规则