pagination help - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: pagination help (/showthread.php?tid=26258) |
pagination help - El Forum - 01-09-2010 [eluser]dadamssg[/eluser] im getting a mysql error with my query for some reason... heres the function in my model Code: function get_events($num, $offset) and heres my controller Code: $this->load->library('pagination'); heres the error im getting Quote:A Database Error Occurred any idea whats goin on here? pagination help - El Forum - 01-09-2010 [eluser]WebsiteDuck[/eluser] You need to order by a column in your table (maybe end?) ORDER BY end ASC pagination help - El Forum - 01-09-2010 [eluser]dadamssg[/eluser] alright well thats one fix. If i just go to mysite.com/mains/index/ and theres no 3rd segment in my uri i get a sql error. but i go to say mysite.com/mains/index/3 i get results BUT the 3rd segment is being assigned to my limit. so if its 'index/1' ill get one row pulled up, 'index/2' will pull up two rows, etc. And my links on my view page aren't correct at all. No matter what i input for the 3 segment in my uri im always on page 1 and i noticed that page two link is 'mysite.com/mains/index/5' instead of 'mysite.com/mains/index/2'. wtf pagination help - El Forum - 01-09-2010 [eluser]WebsiteDuck[/eluser] Ah well, the first thing I would change is in your controller function, do this: Code: somefunction($page=null) Secondly, you need to multiply your offset by your $config['per_page'] Code: if (isset($page) && is_int($page)) That should get rid of the mysql error if no page is specified too pagination help - El Forum - 01-09-2010 [eluser]dadamssg[/eluser] not sure i get what to do with this Code: somefunction($page=null) pagination help - El Forum - 01-09-2010 [eluser]WebsiteDuck[/eluser] It's the function in your controller, you didn't include it in your first post so I don't know what your function is called, could be index? Code: index($page=null) pagination help - El Forum - 01-09-2010 [eluser]dadamssg[/eluser] im not seeing how $page gets assigned to the third uri segment? pagination help - El Forum - 01-09-2010 [eluser]WebsiteDuck[/eluser] Passing URI segments to your functions Also I noticed in your model you have $num and $offset switched. It should be LIMIT $offset, $num Thats why page 2 returns 2 rows pagination help - El Forum - 01-09-2010 [eluser]dadamssg[/eluser] god this is frustrating i don't know what im doing wrong heres my Frontmodel Code: class Frontmodel extends Model { and heres my controller Code: ?php the 3rd uri segment isnt corresponding with the page links and it only pull ups the first 5 rows when i have like 70 somethin in the db pagination help - El Forum - 01-09-2010 [eluser]dadamssg[/eluser] and every link pulls up the same first five rows |