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

ci自带分页,当前页一直在第一页?

[复制链接]
发表于 2014-3-10 21:11:01 CI中国手机版 | 显示全部楼层 |阅读模式
30CI币
怎么回事

发表于 2014-3-11 19:40:24 | 显示全部楼层
$config['uri_segment']设置成你要读取的uri位置
回复

使用道具 举报

 楼主| 发表于 2014-3-11 21:54:31 | 显示全部楼层
PHP复制代码
 
//文章管理控制器
        class Post extends AdminController{
               
                //类目管理
                public function objectManage(){
                        $this->load->helper('form');
                        $this->load->library('form_validation');
                        $this->load->model('category_model','category');
                        $this->load->library('pagination');
                        $this->form_validation->set_rules('object', '类型', 'required');
       
                        //求出总数据条数
                        $total_rows = $this->category->getCount();
                       
                        //分页设置
                        //$config['url_segment'] = 4;
                        $page_size = 5;
                        $config['base_url'] = site_url('admin/post/objectManage');
                        $config['total_rows'] = $total_rows;
                        $config['per_page'] = $page_size;
                        $config['url_segment'] = 4;
                        $config['full_tag_open'] = '<p>';
                        $config['full_tag_close'] = '</p>';
                        //$config['cur_tag_open'] = '<a class="current">';
                        //$config['cur_tag_close'] = '</a>';
                        //$config['num_links'] = 2;
 
                       
                        echo $this->pagination->initialize($config);
                       
                        //查询
                        $offset = intval($this->uri->segment(4));
                        $list = $this->category->look($offset,$page_size);
                        $links = $this->pagination->create_links();
                        $data = array('list'=>$list,
                                                'links'=>$links);
                       
                        if ($this->form_validation->run() == FALSE)
                        {       //验证失败  就返回本页面,显示错误信息;
                                $this->render('admin/post/objectManage',$data);
                               
                        }
                        else
                        {       //验证成功
                                //$this->load->model('category_model','category');
                                $category_name = $this->input->post('object',TRUE);
                                $result = $this->category->insert($category_name);
                               
                                $this->skip($result,'admin/post/objectManage','admin/post/objectManage/');
                        }
                       
                }
               
                public function postRelease(){
                        $this->load->helper('form');
                        $this->load->library('form_validation');
                        $this->load->model('category_model','category');
                        $this->form_validation->set_rules('object', '类型', 'required');
                       
                        $this->render('admin/post/postRelease');
                }
               
               
        }
 
复制代码
回复

使用道具 举报

 楼主| 发表于 2014-3-11 21:55:13 | 显示全部楼层
该设置都设置了啊  ,为什么当前页一直在1 上面啊
回复

使用道具 举报

发表于 2014-3-12 09:07:38 | 显示全部楼层
本帖最后由 一叶扁舟 于 2014-3-12 09:10 编辑

total_rows满足分页情况下,links能不能正常生成?
显示的是第一页是内容是第一页还是links显示第一页?
回复

使用道具 举报

发表于 2014-3-12 11:28:48 | 显示全部楼层
没详情,没代码,没应用环境~ 说个蛋的问题~
回复

使用道具 举报

发表于 2014-4-11 16:19:08 | 显示全部楼层
我的正好反的,第一页数据获取不到
回复

使用道具 举报

发表于 2014-8-29 10:48:08 | 显示全部楼层
你base_url要带上哪些参数和偏移量
回复

使用道具 举报

发表于 2014-8-30 17:30:24 | 显示全部楼层
我也遇到了同样的问题,不知道该怎么解决
回复

使用道具 举报

发表于 2014-8-30 17:38:34 | 显示全部楼层
试下这样看看:$config['total_rows'] = $this->db->get('表名')->num_rows();
回复

使用道具 举报

本版积分规则