pagination help |
[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?
[eluser]WebsiteDuck[/eluser]
You need to order by a column in your table (maybe end?) ORDER BY end ASC
[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
[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
[eluser]dadamssg[/eluser]
not sure i get what to do with this Code: somefunction($page=null)
[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)
[eluser]dadamssg[/eluser]
im not seeing how $page gets assigned to the third uri segment?
[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
[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
|
Welcome Guest, Not a member yet? Register Sign In |