Welcome Guest, Not a member yet? Register   Sign In
Pagination pager problem
#1

[eluser]Corbee[/eluser]
Hi everyone, something funny happened to my code.
whenever I click a number on the pager, it will navigate to that page, but the pager always remains in page 1

1 2 3 >

example when you click number 2 it will still display the same page number, but will display the next page. And the next[>] is not working correctly.

here is my code for controller
Code:
function pdcat($id,$name)
    {
        //initializing pagination configuration
        $config['base_url'] = base_url().'index.php/products/pdcat/'.$id.'/'.$name;
        //selecting the database
        $this->db->select('cat_id');
        $this->db->where('cat_id',$id);
        $this->db->from('product');
        //counting the database
        $config['total_rows'] = $this->db->count_all_results();
        //other configs        
        $config['per_page'] = '9';
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        
        $this->pagination->initialize($config);
        //end of config
        
        $data['title'] = $name;
        $data['navlist'] = $this->MCats->getcategoriesnav();
        $data['products'] = $this->MCats->getcatpd($id,$config['per_page'],$this->uri->segment(5));
        $data['main'] = "pd_home";
        $this->load->view('template',$data);
    }

model

Code:
function getcatpd($id,$num, $offset)
    {
        $data = array();
        $this->db->select('pd_id, pd_name, pd_sdesc, thumb_url, cat_id');
        $this->db->where('cat_id',$id);
        $q = $this->db->get('product',$num, $offset);
        if ($q->num_rows() > 0)
        {
            foreach ($q->result_array() as $row)
            {
                $data[] = $row;    
            }
            $q->free_result();
            return $data;    
        }
    }

Does anyone knows how to fix this?

Thanks
#2

[eluser]Corbee[/eluser]
nevermind found the solution from this link. Thanks for everyone's time though.

http://ellislab.com/forums/viewthread/161502/




Theme © iAndrew 2016 - Forum software by © MyBB