Welcome Guest, Not a member yet? Register   Sign In
pagination help
#9

[eluser]dadamssg[/eluser]
god this is frustrating i don't know what im doing wrong heres my Frontmodel

Code:
class Frontmodel extends Model {



    function Frontmodel()

    {

        parent::Model();

    }

     function get_events($num = NULL, $offset = NULL)
     {
    $query = $this->db->query("SELECT * FROM test WHERE end >= NOW() order by start asc LIMIT $offset, $num");    
    return $query;
     }

and heres my controller
Code:
?php

class Mains extends Controller {

    function Mains()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('date');
        $this->load->helper('text');
        $this->load->helper('form');
        $this->load->library('session');
        $this->load->library('form_validation');
    }

    function index($page)
    {
    $newdata = array(
                   'page'  => 'mains',
               );
        $this->session->set_userdata($newdata);
        $data['title'] = "Home";
        $data['heading'] = "All Events";
        //$this->load->model('Frontmodel');
        //$data['query'] = $this->Frontmodel->get_all_events();
        
        $this->load->library('pagination');
        $config['base_url'] = 'http://mysite.com/mains/index/';
        $config['total_rows'] = $this->db->count_all('test');
        $config['per_page'] = '5';
        $config['uri_segment'] = '3';
        $this->pagination->initialize($config);
        
        //load the model and get results
        $this->load->model('Frontmodel');
        if (isset($page) && is_int($page))
            {
              $offset = $page * $config['per_page'];
            }
            else
            {
              $offset = 0;
            }
        $data['query'] = $this->Frontmodel->get_events(5,$offset);
            

        $this->load->model('Loginmodel');
        $data['notifications'] = $this->Loginmodel->get_notifications();
        $this->load->model('Loginmodel');
        $data['messages'] = $this->Loginmodel->get_messages();
        $this->load->view('header_view', $data);
        
        if($this->session->userdata('logname') == "")
        {
        $this->load->view('login_view', $data);
        }
        else
        {
        $this->load->view('logged_view', $data);
        }
        
        $this->load->view('main_view', $data);
    }

the 3rd uri segment isnt corresponding with the page links and it only pull ups the first 5 rows when i have like 70 somethin in the db


Messages In This Thread
pagination help - by El Forum - 01-09-2010, 07:34 PM
pagination help - by El Forum - 01-09-2010, 07:54 PM
pagination help - by El Forum - 01-09-2010, 08:09 PM
pagination help - by El Forum - 01-09-2010, 08:16 PM
pagination help - by El Forum - 01-09-2010, 08:27 PM
pagination help - by El Forum - 01-09-2010, 08:44 PM
pagination help - by El Forum - 01-09-2010, 08:47 PM
pagination help - by El Forum - 01-09-2010, 08:55 PM
pagination help - by El Forum - 01-09-2010, 09:05 PM
pagination help - by El Forum - 01-09-2010, 09:08 PM
pagination help - by El Forum - 01-09-2010, 09:18 PM
pagination help - by El Forum - 01-09-2010, 09:21 PM
pagination help - by El Forum - 01-09-2010, 09:31 PM
pagination help - by El Forum - 01-09-2010, 09:33 PM
pagination help - by El Forum - 01-09-2010, 09:34 PM
pagination help - by El Forum - 01-09-2010, 09:36 PM
pagination help - by El Forum - 01-09-2010, 09:40 PM
pagination help - by El Forum - 01-09-2010, 09:49 PM
pagination help - by El Forum - 01-09-2010, 10:01 PM
pagination help - by El Forum - 01-09-2010, 10:02 PM
pagination help - by El Forum - 01-09-2010, 10:05 PM
pagination help - by El Forum - 01-09-2010, 10:06 PM
pagination help - by El Forum - 01-09-2010, 10:10 PM
pagination help - by El Forum - 01-09-2010, 10:19 PM
pagination help - by El Forum - 01-10-2010, 07:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB