CodeIgniter Forums
Pagination Next/Previous linking to wrong page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Pagination Next/Previous linking to wrong page (/showthread.php?tid=81155)



Pagination Next/Previous linking to wrong page - night_day - 01-28-2022

Hi everyone,
I'm trying to implement pagination on some data and it works great.  The only issue is that the Next link goes to the wrong page.
PHP Code:
$data = [
            'title' => 'Character',
            'character' => $character,
            'collection' => $modelCharacterCards
                
->table('character_cards')
                ->select('cards.name, character_cards.qty ')
                ->join('cards''character_cards.cardid = cards.id')
                ->where('character_cards.characterid'$characterid)
                ->paginate(2),
            'pager' => $modelCharacterCards->where('characterid'$characterid)->pager,
        ];

There are 14 rows returned in this query.  The join is 1-1 relationship.

My pager has the right links for pages 1,2,and Last on initial load.  Only the Next link is bad The next link is going to page 4 where I would expect page 2.  When I go to the last page (page 8), Previous link is going to page 5.  Not sure what I am missing herelet me know if you have thoughtsthanks



RE: Pagination Next/Previous linking to wrong page - kenjis - 01-28-2022

You need to customize the links.
https://codeigniter4.github.io/userguide/libraries/pagination.html#customizing-the-links


RE: Pagination Next/Previous linking to wrong page - InsiteFX - 01-29-2022

If it's for Bootstrap I already made the pager links for it search the forms there a whole tutorial on how to do it.