Welcome Guest, Not a member yet? Register   Sign In
[ Pagination ] Help, the current page won't change...
#1

[eluser]masipung[/eluser]
Hi all,
Sorry my english not good enough.

I have created pagination. When i click page 2, all of contents in site changed into page 2 but the link page still in page 1.
Here my code.

Controller:
Code:
function Playvideo($lokasi)
    {
    $this->load->library('pagination');
        $config['base_url'] = base_url().'welcome/playvideo/'.$lokasi;
        $config['total_rows'] = $this->db->count_all('view');
        $config['per_page'] = '10';
        $config['first_link'] = 'First';
        $config['last_link'] = 'Last';
        $config['next_link'] = 'Next';
        $config['prev_link'] = 'Previous';
        $this->pagination->initialize($config);
        $data['item']=$this->Mview->showAll($config['per_page'],$this->uri->segment(4));
    $data['play']=$this->Mview->play($lokasi);
    $this->load->vars($data);
        $this->load->view('home');
    }

Model:

Code:
function showAll($num,$offset)
{
    $data=array();
    $this->db->select('id,lokasi,type');
    $this->db->where('status','active');
    $q=$this->db->get('view', $num, $offset);
        
    if($q->num_rows()>0)
        {
            foreach($q->result_array() as $row)
            {
                $data[]=$row;
            }
        }
    $q->free_result();
    return $data;
    }
        

function play($lokasi)
{
    $data=array();
    $this->db->where('id',$lokasi);
    $this->db->where('status','active');
    $q=$this->db->get('view');
    
    if($q->num_rows()>0)
        {
        foreach($q->result_array() as $row)
            {
                $data[]=$row;
            }
        }
        
    $q->free_result();
    return $data;
}

Does anyone can help me??





*still learning english and CI
#2

[eluser]TheFuzzy0ne[/eluser]
What's the request URI on page 2?

Example: /forums/viewthread/2/
#3

[eluser]masipung[/eluser]
http://localhost/polri1/welcome/playvideo/8/10
#4

[eluser]TheFuzzy0ne[/eluser]
The pagination class gets the page number from the 3rd URI segment, and I'm guessing that segment 4 in your URI is the page number.

This might fix your problem.
Code:
$config['uri_segment'] = 4;
#5

[eluser]masipung[/eluser]
Great, that works.

But, how does it work like that?
I have set up the uri_segment = 4 at
Code:
$data['item']=$this->Mview->showAll($config['per_page'],$this->uri->segment(4));
??
#6

[eluser]Thorpe Obazee[/eluser]
that doesn't affect the pagination config settings. I'm guessing that's just your offset for the database query.

You must set the pagination config like Fuzzy posted.
#7

[eluser]masipung[/eluser]
Oh. i know.
Thank's a lot




Theme © iAndrew 2016 - Forum software by © MyBB