兄弟朋友 帮个忙 分页导航条无法显示
CI2.0controllers
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();
} $this->pagination->create_links();应该放在C层,通过变量传到V层去. 非常感谢 我马上试试 还是不行:'( ohmygod 发表于 2011-5-10 18:08 static/image/common/back.gif
还是不行
你先打印出你mode的数据吧....看有没有查询出数据 回复 zhouli520 的帖子
哥们 查询出来了 C
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
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 if(isset($fy)) echo $fy;?>
直接给你我的实例参考下吧 回复 zhouli520 的帖子
谢谢兄弟
页:
[1]