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

[eluser]Unknown[/eluser]
Hi guys,
I read many topics but I don't see my solution. I have integrated the code in my model:

class Data_model extends CI_Model {

function getAll() {

$config['base_url'] = 'http://www.mysite.org/site/index/';
$this->load->library('pagination');
$config['total_rows'] = $this->db->get('data')->num_rows();
$config['per_page'] = '5';
$this->pagination->initialize($config);

$q = $this->db->query("SELECT * FROM data order by submission_time desc");
if($q->num_rows() > 0){
foreach($q->result() as $row)
{
$data[] = $row;
}
return $data;
}
}
}

Now I see the pagination div < 1 2 > but the page 1 and 2 are identical. the pagination links work:
http://www.mysite.org/site/index/1
http://www.mysite.org/site/index/2
http://www.mysite.org/site/index/3

but the articles in homepage are not limited and the pages are identical.

Can you help me please?
#2

[eluser]cideveloper[/eluser]
That because you are not doing a limit, offset in your sql statement. e.g.

Code:
$limit= 10;
$offset = (int) $this->uri->segment(3, 0);
$config['base_url'] = base_url(). 'controller/function/';
$config['total_rows'] = $this->db->get('data')->num_rows();;
$config['per_page'] = $limit;
$config['num_links'] = 5;
$q = $this->db->limit($limit,$offset)->get('data');
#3

[eluser]Unknown[/eluser]
Thank you Smile




Theme © iAndrew 2016 - Forum software by © MyBB