[eluser]Corey Freeman[/eluser]
Sorry if I'm such a newb...I finally figured out models and am attempting to paginate a list of players for my browser game. This is what I ended up with for my controller:
Code:
<?php
class Players extends Controller {
function Players()
{
parent::Controller();
$this->load->library('pagination');
}
function index()
{
redirect('players/list_players/');
}
function list_players() {
$this->load->model('players_model');
$per_page = 1;
$total = $this->players_model->count_players();
$data['players'] = $this->players_model->get_players($per_page, $this->uri->segment(3));
$base_url = site_url('players/list');
$config['base_url'] = $base_url;
$config['total_rows'] = $total;
$config['per_page'] = $per_page;
$config['uri_segment'] = '3';
$this->pagination->initialize($config);
$data['title'] = 'Richest Bloggers';
$this->db->order_by('revenue', 'desc');
$data['query'] = $this->db->get('players');
$this->load->view('players', $data);
}
}
?>
(there are only two players in the database, that's why the number of results is so low.) I end up with a 404 error when I click the next button. Help?