Welcome Guest, Not a member yet? Register   Sign In
Pagination problem!
#11

[eluser]WebbHelp[/eluser]
Code:
function imagegallery()
    {
        
        $id = $this->db->query("SELECT id FROM pages WHERE menu = '". $this->uri->segment(3) ."'");
        $id = $id->row();
        $pageinfo = $this->db->query("SELECT * FROM imagegallery WHERE page = ". intval($id->id));
            $pageinfo = $pageinfo->row();

        $images = $this->db->query("SELECT * FROM images WHERE page = ". intval($id->id));
        
        $this->load->library('pagination');

        $config['base_url'] = site_url('page/imagegallery/'. $this->uri->segment(3));
        echo $config['base_url'];
        $config['total_rows'] = $images->num_rows();
        $config['per_page'] = '2';
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        $config['uri_segment'] = '4';
        
        echo '<br />'. $images->num_rows() .'<br />';

        $this->pagination->initialize($config);
        
        
        
        $header['generalinfo']    =   $this->general; //Data from general table
        $header['title']          =   $pageinfo->title; //Page title
        $header['menuquery']      =   $this->menu; //The menu
        $header['standardpage']   =   $this->standard_menu; //The standardpage
        $content['head']          =   $pageinfo->head;
        $content['images']        =   $this->db->query("SELECT * FROM images WHERE page = ". intval($id->id) ." ORDER BY id DESC LIMIT ". $config['per_page'] ." , ". $this->uri->segment(4));
        $footer['copyright']      =   $this->general->copyright; //General setting: copyright
        
        $this->load->view('header', $header);
        $this->load->view('imagegallery', $content);
        $this->load->view('footer', $footer);
    }

This Smile
#12

[eluser]skylerrichter[/eluser]
its hard to say exactly cause I don't know what your database stucture looks like, but you need to add your limit and offset to your images query $images = $this->db->query("SELECT * FROM images WHERE page = ". intval($id->id))

typicaly it would look like this

$this->db->limit(2, $this->uri->segment(4))

where '2' is the amount of images you want to show per page, and $this->uri->segment(4) is the offset determined by the pagination class.

here is a quick screencast on the pagination class http://net.tutsplus.com/videos/screencas...agination/
#13

[eluser]WebbHelp[/eluser]
Thanks but I do it in this line:

$content['images'] = $this->db->query("SELECT * FROM images WHERE page = ". intval($id->id) ." ORDER BY id DESC LIMIT ". $config['per_page'] ." , ". $this->uri->segment(4));

Close to the end of the code I sent.
Isn't that right or?

Thanks Smile
#14

[eluser]WebbHelp[/eluser]
I tried your:

Code:
function imagegallery()
    {
        
        $id = $this->db->query("SELECT id FROM pages WHERE menu = '". $this->uri->segment(3) ."'");
        $id = $id->row();
        $pageinfo = $this->db->query("SELECT * FROM imagegallery WHERE page = ". intval($id->id));
            $pageinfo = $pageinfo->row();
        
        $images = $this->db->query("SELECT * FROM images WHERE page = ". intval($id->id) ." ORDER BY id DESC LIMIT 2,". $this->uri->segment(4) ."");
        
        $this->load->library('pagination');

        $config['base_url'] = site_url('page/imagegallery/'. $this->uri->segment(3));
        echo $config['base_url'];
        $config['total_rows'] = $images->num_rows();
        $config['per_page'] = '2';
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        $config['uri_segment'] = '4';
        
        echo '<br />'. $images->num_rows() .'<br />';

        $this->pagination->initialize($config);
        
        
        
        $header['generalinfo']    =   $this->general; //Data from general table
        $header['title']          =   $pageinfo->title; //Page title
        $header['menuquery']      =   $this->menu; //The menu
        $header['standardpage']   =   $this->standard_menu; //The standardpage
        $content['head']          =   $pageinfo->head;
        $content['images']        =   $this->db->query("SELECT * FROM images WHERE page = ". intval($id->id) ." ORDER BY id DESC LIMIT ". $config['per_page'] ." , ". $this->uri->segment(4));
        $footer['copyright']      =   $this->general->copyright; //General setting: copyright
        
        $this->load->view('header', $header);
        $this->load->view('imagegallery', $content);
        $this->load->view('footer', $footer);
    }

Now I got:
$images = $this->db->query("SELECT * FROM images WHERE page = ". intval($id->id) ." ORDER BY id DESC LIMIT 2,". $this->uri->segment(4) ."");

But it doesn't work!




Theme © iAndrew 2016 - Forum software by © MyBB