从2个字段'位置搜索'和' resTitle' 。使用' resTitle'进行搜索时,代码可以正常分页。但使用' location'进行搜索时,分页标签会消失。
控制器---
$search = ($this->input->get("resTitle"))? $this->input->get("resTitle") : "NIL";
$search = ($this->uri->segment(3)) ? $this->uri->segment(3) : $search;
$searchLoc = ($this->input->get("location"))? $this->input->get("location") : "NIL";
$searchLoc = ($this->uri->segment(3)) ? $this->uri->segment(3) : $searchLoc;
if($this->input->get("resTitle")!= 'null'){
$total_row_res= $this->common_model->res_count($search,"") ;
$limit = 3;
$config = array();
$config["uri_segment"] = 4;
$config['base_url'] = base_url()."res_search/index/$search";
$config['per_page'] = $limit;
$config['use_page_numbers'] = TRUE;
$config['first_url'] = '1';
$config['total_rows'] = $total_row_res;
$data['result']=$search;
$data['total_row_res'] = $total_row_res;
}
else{
$total_row_loc= $this->common_model->res_count("",$searchLoc) ;
$limit = 3;
$config = array();
$config["uri_segment"] = 4;
$config['base_url'] = base_url()."res_search/index/$searchLoc";
$config['per_page'] = $limit;
$config['use_page_numbers'] = TRUE;
$config['first_url'] = '1';
$config['total_rows'] = $total_row_loc;
$data['resultLoc']=$searchLoc;
$data['total_row_loc'] = $total_row_loc;
}
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$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);
$data['page'] = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
$data['offset'] = ($data['page'] == 0 ? 0 : ($data['page'] - 1) * $limit);
$data['searchList'] = $this->common_model->search($this->table, $search, $searchLoc, $limit, $data['offset']);
$data['pagination'] = $this->pagination->create_links();
$data['start'] = ($data['page'] == 0 ? 1 : (($data['page']-1) * $limit + 1)); `
视图---------
<div class="col-xs-12 col-sm-12">
<?php
foreach ($searchList as $row){?>
<article class="search-result row">
<div class="col-xs-12 col-sm-12 col-md-7 excerpet">
<p><?= $start; ?></p>
<p class="text-success"><?php echo $row->type_name; ?></p>
<h3><a href="#" title=""><?php echo $row->res_name; ?></a></h3>
<p ><?php echo $row->loc_name; ?></p>
<p > <?php echo $row->add_details;?>, <?php echo $row->loc_name; ?>, <?php echo $row->city_name; ?></p>
<p >CUISINES: <?php echo $row->cuisine_name; ?></p>
<p >COST FOR TWO: ₹<?php echo $row->cost; ?></p>
<p> <?php echo $row->contact; ?></p>
</div>
<span class="clearfix borda"></span>
</article>
<?php
$start++;
} ?>
</div>
<div>
<?php echo $pagination; ?>
</div>