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

[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?


Messages In This Thread
Basic Pagination Help? - by El Forum - 07-03-2010, 07:59 PM
Basic Pagination Help? - by El Forum - 07-03-2010, 10:27 PM
Basic Pagination Help? - by El Forum - 07-04-2010, 01:07 AM
Basic Pagination Help? - by El Forum - 07-04-2010, 04:11 PM
Basic Pagination Help? - by El Forum - 07-04-2010, 11:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB