![]() |
YAPI (Yet Another Pagination Issue) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: YAPI (Yet Another Pagination Issue) (/showthread.php?tid=52640) |
YAPI (Yet Another Pagination Issue) - El Forum - 06-19-2012 [eluser]cpass78[/eluser] OK Im stumped... For some stupid reason i can't get the links to show in my view and i spent more time on it then i like so I'm turning to the community for assistance. Controller code Code: public function listTodos() { Model code Code: function listTados($userid, $orderby, $sort, $limit, $offset) { In my view i echo out $paginate, all pretty easy stuff right.. The strange thing is that in profiler my query looks like so Code: SELECT * The offset is not getting passed unless i switch the vars passed to the model but then i only get one record returned and the offset is shown. Any clues? Thank you YAPI (Yet Another Pagination Issue) - El Forum - 06-19-2012 [eluser]CroNiX[/eluser] Code: echo $config['total_rows'] = count($todos); //prints out 5 correctly out of 9 records total_rows should be the grand total number of rows in your table, not how many results are in the current resultset (which would be only 5 at a time if your per_page is 5). If this number isn't correct it can't calculate the page offsets and number of pages (total_rows / per_page (rounded up) = number of pages). So, that should be 9, not 5. If your per_page was 5 and you had less than 5 total_rows, there would be only 1 page (the current page) and pagination links wouldn't show, which is what's happening. You need 2 queries. One to get the current results for the current page number (using offset/limit), and the other to get the total rows in the table using the exact same criteria as you use for the first query (all wheres, etc), except no limit/offset. YAPI (Yet Another Pagination Issue) - El Forum - 06-19-2012 [eluser]cpass78[/eluser] see to much time spent... figured it was something stupid i missed. Thank you bud |