哈希賣铺 发表于 2014-3-10 21:11:01

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

怎么回事

一叶扁舟 发表于 2014-3-11 19:40:24

$config['uri_segment']设置成你要读取的uri位置

哈希賣铺 发表于 2014-3-11 21:54:31


//文章管理控制器
        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显示第一页?

IvanCI 发表于 2014-3-12 11:28:48

没详情,没代码,没应用环境~ 说个蛋的问题~

goyuquan 发表于 2014-4-11 16:19:08

我的正好反的,第一页数据获取不到

冠希丶 发表于 2014-8-29 10:48:08

你base_url要带上哪些参数和偏移量

Cosplay 发表于 2014-8-30 17:30:24

我也遇到了同样的问题,不知道该怎么解决

Cosplay 发表于 2014-8-30 17:38:34

试下这样看看:$config['total_rows'] = $this->db->get('表名')->num_rows();
页: [1] 2
查看完整版本: ci自带分页,当前页一直在第一页?