控制器功能:
function search_branch()
{
$this->load->library('pagination');
$search_this=$this->input->post('inputsearchbranch');
$limit = 20;
$data['fields'] = array(
'branch_name' => 'Branch Name',
'city'=>'City',
'district'=>'District',
'tahsil'=>'Tahsil',
'Branch_manager'=>'Branch Manager'
);
$this->load->model('mod_user');
$searchbranch=$this->mod_user->search_branch($search_this,$limit);
$data['searchbranch'] = $searchbranch;
$config = array();
$config['base_url'] = site_url("ctl_home/search_branch/");
$config['total_rows'] = count($searchbranch);
$config['per_page'] = $limit;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->load->view('view_searchbranch',$data);
}
我的观点:
<center>
<form class="userinfo" action="" method="post">
//table in which search record display
</form>
</center>
<?php if (strlen($pagination)): ?>
<div class="pagination">
<?php echo $pagination; ?>
</div>
<?php endif; ?>
答案 0 :(得分:0)
尝试将"$config['uri_segment'] = 3;"
更改为$config['uri_segment'] = 5
;
你用有限的记录计算总数。总计数值将与所有记录一起计算。
答案 1 :(得分:0)
function search_branch()
{
$this->load->library('pagination');
$search_this=$this->input->post('inputsearchbranch');
$limit = 20;
$data['fields'] = array(
'branch_name' => 'Branch Name',
'city'=>'City',
'district'=>'District',
'tahsil'=>'Tahsil',
'Branch_manager'=>'Branch Manager'
);
$this->load->model('mod_user');
$searchbranch=$this->mod_user->search_branch($search_this,false);
$config['total_rows'] = count($searchbranch);
$searchbranch=$this->mod_user->search_branch($search_this,$limit);
$data['searchbranch'] = $searchbranch;
$config = array();
$config['base_url'] = site_url("ctl_home/search_branch/");
$config['per_page'] = $limit;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->load->view('view_searchbranch',$data);
}
答案 2 :(得分:0)
&安培;也用
$offset = $this->uri->segment(4);
将新参数添加到search_branch函数并将其传递给db ..
$searchbranch=$this->mod_user->search_branch($search_this,$limit,$offset);
示例函数($ where,$ limit,$ offset)
$this->db->where($where);
$query = $this->db->get('mytable', $limit, $offset);