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

[eluser]junaids[/eluser]
I have a little problem with pagination. when i click on the next link, the same records are shown every time
here my controler
Code:
function home($row=0)
     {        
        $config['base_url'] = 'http://localhost/codeigniter/index.php/events/home/';
        $config['total_rows']=$this->eventsmodel->getNumEvents();
        $config['per_page'] = '5';
        $this->pagination->initialize($config);

            $data['css'] = $this->css;
               $data['base'] = $this->base;
              $allevents = $this->eventsmodel->getallEvents($row=0);
            $data['events'] = $allevents;
            $data['links']=$this->pagination->create_links();
            $this->load->view('events/home', $data);
    }

and model
Code:
function getallEvents($row) {
    $Q = $this->db->get('event',5,$row);
    if ($Q->num_rows() > 0) {
        return $Q->result();
       } else {
         return FALSE;
    }
}
#2

[eluser]pistolPete[/eluser]
I guess this line should be changed from

Code:
$allevents = $this->eventsmodel->getallEvents($row=0);

to
Code:
$allevents = $this->eventsmodel->getallEvents($row);
#3

[eluser]junaids[/eluser]
no effect
#4

[eluser]n0xie[/eluser]
What results do you get if you call it like this:
Code:
$this->eventsmodel->getallEvents(5);
$this->eventsmodel->getallEvents(10);
$this->eventsmodel->getallEvents(15);
#5

[eluser]junaids[/eluser]
from
$this->eventsmodel->getallEvents(5);
i get 5 results on page and same five on the next page

using
$this->eventsmodel->getallEvents(10);

i get only 1 result
#6

[eluser]n0xie[/eluser]
That shows that the offset is working correctly.

What are the links that are constructed by the pagination class?
It should be something like this on the frontpage:
Code:
<a href="http://localhost/codeigniter/index.php/events/home/5">page 2</a>
#7

[eluser]junaids[/eluser]
the links are like this
Code:
<p>&nbsp;<b>1</b>&nbsp;<a href="http://localhost/codeigniter/index.php/events/home/AMPper_page=5">2</a>&nbsp;<a href="http://localhost/codeigniter/index.php/events/home/AMPper_page=10">3</a>&nbsp;<a href="http://localhost/codeigniter/index.php/events/home/AMPper_page=5">&gt;</a>&nbsp;</p>
#8

[eluser]n0xie[/eluser]
Do you have QUERY_STRING enabled? Because the url is build by the pagination class is wrong.
#9

[eluser]junaids[/eluser]
yes i have that enabled in config file
#10

[eluser]n0xie[/eluser]
I have no idea how pagination class works with QUERY_STRING enabled. You should look into the userguide, or maybe someone else can help you.




Theme © iAndrew 2016 - Forum software by © MyBB