[eluser]truongdd[/eluser]
//Controller
function search(){
$this->load->library('pagination');
if ($this->input->post('s'))
{
$this->session->set_userdata('keyword', $this->input->post('s'));
}
$config['base_url'] = site_url().'kienvang/search/';
$config['total_rows'] = $this->MClassifieds->search_count($this->session->userdata('keyword'));
$config['per_page']=5;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
//load the model and get results
//$this->load->model('mnews');
$data['results'] = $this->MClassifieds->search($config['per_page'],(int) $this->uri->segment(3),$this->session->userdata('keyword'));
$data['title'] = "Kien Vang | Search Results";
$data['menulist'] =$this->MCategories->getCategoriesMenu();
$this->load->vars($data);
$this->load->view('search');
}
///model
function search_count($s){
$data = array();
$this->db->select('id,title,content,created,region');
$this->db->like('title',db_clean($s));
$this->db->orlike('content',db_clean($s));
$this->db->orderby('title','asc');
$this->db->where('status','active');
$Q = $this->db->get('classifieds');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function search($limit,$offset,$s)
{
$data = array();
$this->db->select('id,title,content,created,region');
$this->db->like('title',$s);
$this->db->orlike('content',$s);
$this->db->orderby('title','asc');
$this->db->where('status','active');
$Q = $this->db->get('classifieds',$limit,$offset);
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
//view
<?php
echo "<h3 class='home'>"."Search Results"."</h3>";
echo "<div class='post'>";
if(count($results)){
foreach($results as $key=>$list){
echo "<h3 class='title'>";
echo anchor('kienvang/classified/'.$list['id'],$list['title']);
echo "</h3>";
echo "<p class='byline'><small>".$list['created']." | ".$list['region']."</small></p>";
}
}
echo "</div>";
echo $this->pagination->create_links();
?>
problem:
Fatal error: Unsupported operand types in F:\xampp\htdocs\kienvang\system\libraries\Pagination.php on line 112.
wish someone for help.Thank!