Welcome Guest, Not a member yet? Register   Sign In
Pagination, Problem passing per_page and offset in my query(SOLVED)
#2

[eluser]srpurdy[/eluser]
Ok I solved this,

I got hung up on my query working and being able to count without limiting the amount of results it outputs!

I needed to create a new function to count the specific entry's I wanted like below

Code:
function count_results()
{
    $count_res = $this->db
        ->where('ilr_league.url_league_name', $this->uri->segment(3))
        ->where('ilr_league.league_id = ilr_series.league_id')
        ->where('ilr_season.active', 'N')
        ->select('
            ilr_series.series_id,
            ilr_series.series_title,
            ilr_series.active,
            ilr_season.active
        ')
        ->from('
            ilr_season,
            ilr_league
        ')
        ->order_by('ilr_series.series_id', 'desc')
        ->join('ilr_series', 'ilr_series.series_id = ilr_season.series_id')
        ->get();
    return $count_res;
}

I also added this to my a_show_seasons() function
Code:
->limit($num, $offset)
Also declaring this at the top of the function
Code:
function a_show_seasons($num, $offset)

So my controller now looks like this
Code:
$this->load->library('pagination');
    $config['base_url'] = base_url(). 'archives/champs/' . $this->uri->segment(3);
    $config['per_page'] = '5';
    $config['uri_segment'] = '4';
    $config['num_links'] = '4';

    $data['series'] = $this->archives_model->a_show_series();
    $data['season'] = $this->archives_model->a_show_seasons($config['per_page'],$this->uri->segment(4));
    $data['count_res'] = $this->archives_model->count_results();
    $data['query'] = $this->archives_model->a_show_events();
    $config['total_rows'] =  count($data['count_res']->result());
    $this->pagination->initialize($config);

Maybe it will help someone, to create a function to count with instead of trying to use your original functions! dups! Smile


Messages In This Thread
Pagination, Problem passing per_page and offset in my query(SOLVED) - by El Forum - 01-24-2010, 10:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB