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

[已解决] 兄弟朋友 帮个忙 分页导航条无法显示

[复制链接]
发表于 2011-5-10 17:33:49 | 显示全部楼层 |阅读模式
CI2.0
controllers
function index(){
        $this->load->model('Mindexs');
    //分页地址
    $config['base_url'] = base_url().'index.php/Indexs/index';
    //每页显示数
    $config['per_page'] = 2;
    //分页接收的参数
    $config['uri_segment'] = 3;
    //分页总数
    $data['sum'] = $this->Mindexs->sum();
    //定义第一页
    $config['first_link'] = '首页';
    //定义尾页
    $config['last_link'] = '尾页';
    //定义上一页
    $config['prev_link'] = '上一页';
    //定义下一页
    $config['next'] = '下一页';
   
    $config['full_tag_open'] = '<p>';


    $config['full_tag_close'] = '</p>';

    //实例化
        $this->pagination->initialize($config);
   
    //显示内容
        $data['ms'] = $this->Mindexs->index($config['per_page'],$this->uri->segment(3,0));
  
        $this->load->view('index',$data);
}

html

<a><?php echo $this->pagination->create_links();?></a>


model

        function index($top,$str){

        $this->db->order_by('id','DESC');
      
        $where = array('id >'=>10);

        //搜索10条从0开始
                $query = $this->db->get('kb',$top,$str);
                return $query->result();
                }
发表于 2011-5-10 17:49:30 | 显示全部楼层
$this->pagination->create_links();应该放在C层,通过变量传到V层去.
 楼主| 发表于 2011-5-10 18:05:02 | 显示全部楼层
非常感谢 我马上试试
 楼主| 发表于 2011-5-10 18:08:15 | 显示全部楼层
还是不行
发表于 2011-5-10 18:23:08 | 显示全部楼层
ohmygod 发表于 2011-5-10 18:08
还是不行

你先打印出你mode的数据吧....看有没有查询出数据
 楼主| 发表于 2011-5-10 18:25:48 | 显示全部楼层
回复 zhouli520 的帖子

哥们 查询出来了
发表于 2011-5-10 18:27:57 | 显示全部楼层
C
PHP复制代码
 
function fy($rows, $url, $segment, $perpage) {
                $config ['base_url'] = $url;
                $config ['total_rows'] = $rows;
                $config ['per_page'] = $perpage;
                $config ['uri_segment'] = $segment;
                $this->pagination->initialize ( $config );
                return $this->pagination->create_links ();
        }
function index($row=0){
$user = $this->UserModel->getuserlist($row,10);
$count = $this->UserModel->getusercount();
$url = base_url().'index.php/admins/user/index';
                $data['fy'] = $this->fy($count,$url,4,10);
                $this->load->view('admin/userlist',$data);
}
 
复制代码

M
PHP复制代码
 
function getuserlist($row,$page){
                $sql = "select * from pw_members where uid not in (1,2) order by regdate desc limit $row,$page";
                $query = $this->db->query($sql);
                if($query->num_rows()>0){
                        return $query->result_array();
                }else{
                        return null;
                }
        }
       
        function getusercount(){
                $sql = "select * from pw_members where uid not in (1)";
                $query = $this->db->query($sql);
                return $query->num_rows();
        }
 
复制代码

V
PHP复制代码
 
<?php if(isset($fy)) echo $fy;?>
 
复制代码


直接给你我的实例参考下吧
 楼主| 发表于 2011-5-10 18:33:36 | 显示全部楼层
回复 zhouli520 的帖子

谢谢兄弟

本版积分规则