[eluser]novarli[/eluser]
My controller script
Code:
$data['count_result'] = $this->cities->count_result($txtName,$province);
$config['total_rows'] = $data['count_result'];
$config['per_page'] = 2;
$offset = $this->uri->segment(3);
$this->load->library('pagination');
$this->pagination->initialize($config);
$data['paging'] = $this->pagination->create_links();
$data['search_res'] = $this->cities->getSearchResult($txtName,$province, $config['per_page'], $offset);
$this->load->view('city/search_res', $data);
The model
Code:
function getSearchResult($city,$province,$limit,$offset){
$this->db->select('cities.id,cities.name as city_name,provinces.name as province_name');
$this->db->from('cities');
$this->db->join('provinces','cities.province = provinces.id');
if (!empty($city))
{
$this->db->like('cities.name',$city);
}
if ($offset)
{
$this->db->limit($limit,$offset);
}
else
{
$this->db->limit($limit);
}
if ($province!=0){
$this->db->where('province', $province);
}
$this->db->order_by('cities.name');
$query = $this->db->get();
return $query->result();
}
function count_result($city,$province)
{
$this->db->select('cities.id,cities.name as city_name,provinces.name as province_name');
$this->db->from('cities');
$this->db->join('provinces','cities.province = provinces.id');
if (!empty($city))
{
$this->db->like('cities.name',$city);
}
if ($province!=0){
$this->db->where('province', $province);
}
return $this->db->get();
}
And view
Code:
...
<?php echo !empty($paging) ? $paging : ''; ?>
then error
Message: Object of class CI_DB_mysql_result could not be converted to int
Filename: libraries/Pagination.php
Line Number: 104
Severity: Notice
Message: Object of class CI_DB_mysql_result could not be converted to int
Filename: libraries/Pagination.php
Line Number: 110
What happen?
Here the screenshot
http://img364.imageshack.us/img364/7103/resultzb0.gif