![]() |
pagination and uri_segment - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: pagination and uri_segment (/showthread.php?tid=49139) |
pagination and uri_segment - El Forum - 02-09-2012 [eluser]fanch[/eluser] Hello! i'm too new to CI to prentend having ancounter a bug. There's must be a mistake in my code! I've read documentation and browsed forums but i can't find where! Any help is welcome: I want to a simple pagination with sorting features. Here is the code: Code: <?php The search function works great, i can type url such like: Quote:http://10.153.9.6/dev/index.php/projects/display/id/desc But the pagination links are wrong, I obtain: Quote:http://10.153.9.6/dev/index.php/projects/display/id/desc/0/240instead of: Quote:http://10.153.9.6/dev/index.php/projects/display/id/desc/240I thought the problem was in the "uri_segment', but I think 5 is the correct value: Code: // base url / 1 / 2 / 3/ 4 / 5 I've missed something. Any idea? thanks! fanch pagination and uri_segment - El Forum - 02-09-2012 [eluser]182armin[/eluser] Hello, I am too new to CI, but i think its beacouse of your offset in function display: Code: function display($sort_by = 'id', $sort_order='desc', $offset = 0) pagination and uri_segment - El Forum - 02-09-2012 [eluser]InsiteFX[/eluser] For help you need to show the code for: Code: $this->project_model->search($limits,$offset,$sort_by, $sort_order); pagination and uri_segment - El Forum - 02-09-2012 [eluser]bosse2nage[/eluser] Thanks Armin but I have to passed $offset in my function display. Haven't I? InsiteFx: sure here is the code of the search function: Code: function search($limits, $offset, $sort_by, $sort_order) { This function works well: when I enter the search criteria "by hand" in the url, it displays the correct result. Note that the SQL query is adapted to Sql-Server. pagination and uri_segment - El Forum - 02-13-2012 [eluser]bosse2nage[/eluser] I have tried to change the "uri_segment" value but no improvements... Best, Bosse pagination and uri_segment - El Forum - 02-13-2012 [eluser]bosse2nage[/eluser] We found the error! The $offset should be removed from the "base_url": Code: $config['base_url']=site_url("projects/display/$sort_by/$sort_order"); instead of Code: $config['base_url']=site_url("projects/display/$sort_by/$sort_order/$offset"); Thanks everyone for your help!!! |