【发布时间】:2017-10-29 18:36:23
【问题描述】:
这是我的控制器:
function index()
{
$data['title']="Post";
$this->load->library('pagination');
$config['base_url'] = base_url().'Post/index';
$config['total_rows'] = $this->post_model->get_total_count();
$config['per_page'] = 1;
$config['uri_segment'] = 1;
$this->pagination->initialize($config);
$data['posts'] = $this->post_model->get_single_post($config['per_page'],$this->uri->segment(1));
$this->load->view('frontend/layouts/header',$data);
$this->load->view('frontend/view_post',$data);
$this->load->view('frontend/layouts/footer');
}
型号
function get_single_post(){
$query= $this->db->select('*')
->from('tbl_post,tbl_users')
->where('tbl_post.post_created=tbl_users.user_id')
->where('tbl_post.post_status',1)
->order_by('tbl_post.post_id','asc')
->get();
$data = $query->result_array();
return $data;
}
function get_total_count(){
$this->db->select('*');
$this->db->from('tbl_post');
$query = $this->db->get();
return $query->num_rows();
}
相关页面数据未显示。它在一页中显示所有数据!
【问题讨论】:
-
您所说的无法显示每页数据是什么意思。 Cz 它在您的代码中
$config['per_page'] = 1; -
它显示了所有的数据库数据。但我想显示每页 1 的数据,但它不能
-
缺少
$data['links'] = $this->pagination->create_links();?? -
我显示它查看页面如下:
<?php echo $this->pagination->create_links();?>
标签: php codeigniter pagination codeigniter-3