Welcome Guest, Not a member yet? Register   Sign In
Pagination doesn't work :s
#1

[eluser]Unknown[/eluser]
Hi guys,
I'm trying to use the pagination library for my website but I have some problems with it.

Here is my controller code:
Code:
class Projets extends CI_Controller
{
public function __construct()
{
  parent::__construct();
  $this->load->model('projets_model', 'projetsManager');
}

public function liste()
{
  $this->load->library('pagination');

  $per_page = 10;
  $total_rows = $this->projetsManager->projets_count();
  $offset = $this->uri->segment(3);
    
  $config['base_url'] = site_url('/projets/liste/');
  $config['total_rows'] = $total_rows;
  $config['per_page'] = $per_page;
  
  $data['categories'] = $this->projetsManager->get_categories();
  $data['pagination'] = $this->pagination->create_links();
  $data['projets'] = $this->projetsManager->get_all_projets($per_page, $offset);
  
  $this->pagination->initialize($config);
  
  $this->load->view('site/projets_view', $data);
  
}
}
Here is my model code:
Code:
class Projets_model extends CI_Model
{
protected $table = 'projets';

        public function projets_count()
{
  return $this->db->count_all($this->table);
}

public function get_all_projets($limit, $offset)
{
  $query = $this->db->get($this->table, $limit, $offset);
  return $query->result();
}
}

And finaly my view code:
Code:
<?php foreach ($projets as $projet) {
echo $projet->title;
}
?>

<?php echo $pagination?>

So it well displays the 10 first projets title but then I have no pagination links.

Please help me I watched many tutorials and my code seems allright I don't understand what's wrong.


Messages In This Thread
Pagination doesn't work :s - by El Forum - 10-28-2013, 02:35 AM
Pagination doesn't work :s - by El Forum - 10-29-2013, 02:15 AM
Pagination doesn't work :s - by El Forum - 10-30-2013, 04:50 AM
Pagination doesn't work :s - by El Forum - 11-01-2013, 09:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB