Codeigniter分页不显示数据

时间:2018-02-22 09:34:02

标签: php codeigniter pagination

我正在使用codeigniter分页,它基于passID显示,第一页只显示链接但没有数据

我的控制器:

public function searchpagenat($hsp)

$config = array();
$config["base_url"] = base_url() . "User/searchpagenat/";
$config['total_rows'] = $this->Doctor_model->get_doc_by_hospital($hsp);
$config['per_page'] = 4;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = 'Prev';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>'; 
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$segment = $this->uri->segment (3);
$data['serv'] = $this->Doctor_model->get_doc_by_hsp($config['per_page'], $segment,$hsp);

和模型

public function get_doc_by_hospital($hsp)  
{ 
$this->db->select('*');  
$this->db->from('tbl_doctor');
$this->db->where('hosp_id',$hsp);
$query = $this->db->get();
return $query->num_rows();
}
public function get_doc_by_hsp($limit, $offset, $hsp)
{
$this->db->select('*');    
$this->db->from('tbl_doctor'); 
$this->db->where('hosp_id',$hsp);
$this->db->limit($limit, $offset);
$query= $this->db->get();  
if($query->num_rows()>0)
{
return $query;
} 

这里查询正在运行的问题是传递id的分页链接工作在传递id的基础上传递id比计数显示没有数据更重要。

它如何解决?任何方式?请帮助我?

0 个答案:

没有答案