![]() |
Pagination not working - 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 not working (/showthread.php?tid=13196) |
Pagination not working - El Forum - 11-14-2008 [eluser]bhakti.thakkar[/eluser] i have a page in which i display all the projects of a particular client. e.g. there are 24 records for a particular client. but i get all the 24 records at a stretch in my view. i have specified 5 records per page but it doesnt work. there are proper ‹ First < 1 2 3 4 5 > on my view page but all 24 records are shown on all the links. what is wrong ? please help me Controller : projects.php: Code: function index() my view : Code: <?php [/code] Pagination not working - El Forum - 11-14-2008 [eluser]julgus[/eluser] Hi, must be something wrong with the limit offset,scope in your sql in the method Code: $this->projects_model->getProjects($lower, $config['per_page']); I use the pagination without any problems in my project. Regards Pagination not working - El Forum - 11-14-2008 [eluser]bhakti.thakkar[/eluser] yes i was not passing the offset and limit properly to my model which i changed as below: Code: function getProjects($offset , $limit) now the links are working but one strange problem is when i open the page 1st time it shows me 5 records. then when i click next, the first five records remain on the same view and next five are appended to it. that means 2nd page has 10 records and this goes on of all the links. the 3rd page has 15 records and i printed the offset and limit and they are geting incremented and passed properly. think there is some problem here : Code: $config['base_url'] = base_url().'index.php/projects/index/'; can anyone figure it out what is wrong? Pagination not working - El Forum - 11-14-2008 [eluser]BaRzO[/eluser] You don't have to use Code: <?php Quote:Notes:if pagination needed. Links will be there but if not there will be empty string and to see what happening you can use profiling you can easily see what is going wrong Pagination not working - El Forum - 11-14-2008 [eluser]Flemming[/eluser] Quote:2nd page has 10 records and this goes on of all the links. the 3rd page has 15 records it sounds like you simply have your limit and offset the wrong way round! Pagination not working - El Forum - 11-15-2008 [eluser]bhakti.thakkar[/eluser] no the limit and offsets are set correctly but the thing is i am using MSSQL DB which doesnt accept offset and limit. i should have specified it right at the first post itself the DB that i am using. i thought its some other issue. but its mssql issue which doesnt support these clauses. Hope i get some crack on it. also in the mean while i will scan this forum's previous all post on this issue. Thanks Pagination not working - El Forum - 11-16-2008 [eluser]bhakti.thakkar[/eluser] still this remains unsolved. can any one please provide any linked on in. i have even scanned all the related posts on this forum and i am not able to get anything work for me. Thanks in advance Pagination not working - El Forum - 11-16-2008 [eluser]bhakti.thakkar[/eluser] I tried the below code which is working but there is only one problem. if for example there are 17 records and if i am setting 15 records per page then on the first page there will be 15 and on the second page instead of remaining 2, it show again 15 i.e. last 2 records + 13 records of previous page. but this is now what is completely ok. below is what i modified in my model. Project_model.php: where $num is the limit function _getProjects($offset, $num) { $relation_id = $this->session->userdata('srelation_id'); $offset = (!$offset) ? 0 : $offset; $next = ($num + $offset); $orderR = "asc"; $where = ''; $sql = 'select * from (' . 'select top ' . $num . ' * from (' . 'select top ' . ($num+$offset-1) . ' * ' . 'from Project_T where Relation_ID = ' .$relation_id. 'order by Project_ID asc) as t1 ' . 'order by Project_ID desc) as t2 ' . 'order by Project_ID asc'; $query = $this->db->query($sql); return $query->result(); } Hope i get the final help on it and it also helps some one. Pagination not working - El Forum - 12-02-2008 [eluser]whobutsb[/eluser] Hey There bhakti.thakkar, I'm in the same situation as you! I'am using a MSSQL DB and trying to use the pagination script and whenever I go to the 2nd page I don't get the next set of results they are just appended to the first set of results. Did you ever figure out why this was happening? Does the CI Pagination method not handle MSSQL DBs? Thanks, in advance, Steve Pagination not working - El Forum - 12-03-2008 [eluser]bhakti.thakkar[/eluser] Hi Steve, The problem is there is no limit and offset clause in MSSQL DB. So even if you specify limit and offset, things are not goin to work. Well, right now , i am using the mechanism i have provided in my previous thread and things are working fine :-) the only problem i am facing is, if suppose there are 19 records and i want 15 records per page, then what happens is on first page 15 records are displayed well but on click of next it shows me again 15 i.e new 4 and previous pages 11 records. it shud be only 4 on the next page logically. but that fine until i find some alternative for it. i have scanned to numerous forums of CI and total scan search in this forum as well, but no solution so far. If i could help you out in any way just let me know!!! :coolsmile: |