我的 codeigniter 应用程序有问题。我已经设置了一个控制器方法,如下所示:
public function program_search()
{
$config['base_url'] = base_url().'/site/program_search/';
$config['total_rows'] = $this->db->get('wc_program')->num_rows();
$config['per_page'] = 15;
$config['num_links'] = 1;
$config["uri_segment"] = 3;
$config['num_links'] = 1;
$config['full_tag_open'] = '<div class="pagination pagination-small"><ul>';
$config['full_tag_close'] = '</ul></div>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '»';
$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 class="page">';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$term = $this->input->post('term');
$this->db->like('JobRef', $term);
$this->db->or_like('Area', $term);
$this->db->or_like('Parish', $term);
$this->db->or_like('WorkType', $term);
$this->db->or_like('Location', $term);
$this->db->order_by('wc_program.JobRef');
$this->db->limit(15, $this->uri->segment(3));
$q = $this->db->get('wc_program');
if($q->num_rows() > 0) {
$data['results'] = $q->result();
}
$data["links"] = $this->pagination->create_links();
$this->front->set('title', 'Search our current programmes');
$this->front->set('metadesc', 'Program Search');
$this->front->set('metakeywords', '');
$this->front->buffer('content', 'site/program_search_results', $data);
$this->front->render();
}
但它会根据在搜索框中输入的内容显示结果,但如果结果少于 15 个,它仍然会显示分页,这是我不想要的。如果结果超过 15 则再次显示我想要的分页,但然后转到下一页那里什么都没有,有人可以从代码中告诉我我做错了什么吗?
我真的被困在哪里出了问题,需要一些帮助......
提前感谢