Welcome Guest, Not a member yet? Register   Sign In
Pagination problem, total_rows
#1

[eluser]Tud[/eluser]
Hello,

I have a problem with pagination. running a search, the first page is correct (for example $data['total_rows'] is = 12) but when I click on the second page $data['total_rows'] contains all rows (in my example 15). :-S
Any idea?

This is my code
controller:
Code:
function search_result() {
.....
$data['total_rows'] = $this->Real->search_count($this->input->post('', TRUE));
$this->load->library('pagination');
$config['base_url'] = site_url('pages/search_result');
$config['per_page'] = 4;
$config['uri_segment'] = '3';
$config['num_links'] = 3;
$config['first_link'] = 'Inizio';
$config['last_link'] = 'Fine';
$config['cur_tag_open'] = '<span class="active_link">';
$config['cur_tag_close'] = '</span>';
$config['total_rows'] = $data['total_rows'];
$this->pagination->initialize($config);

$data['search_result'] = $this->Real->search($this->input->post('', TRUE),$config['per_page'], (int)$this->uri->segment(3));
.....
}
model:
Code:
function search($post, $num, $offset) {
.....
$this->db->where($options_where);
$this->db->where_in($options_where_in);
$this->db->get('reals', $num, $offset);
.....
}

function search_count($post) {
.....
$this->db->where($options_where);
$this->db->where_in($options_where_in);
$Q = $this->db->get('reals');
$num_rows = $Q->num_rows();
return $num_rows;
}
view:
Code:
&lt;?php foreach ($search_result as $s) { ?&gt;
.....
&lt;?php } ?&gt;
<div id="pagination">&lt;?php echo $this->pagination->create_links(); ?&gt;</div>

Thanks
.Stefano


Messages In This Thread
Pagination problem, total_rows - by El Forum - 06-13-2009, 11:10 AM
Pagination problem, total_rows - by El Forum - 06-13-2009, 11:26 AM
Pagination problem, total_rows - by El Forum - 06-13-2009, 12:07 PM
Pagination problem, total_rows - by El Forum - 06-13-2009, 01:02 PM
Pagination problem, total_rows - by El Forum - 06-13-2009, 01:26 PM
Pagination problem, total_rows - by El Forum - 06-13-2009, 01:39 PM
Pagination problem, total_rows - by El Forum - 06-13-2009, 03:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB