Pagination issue |
[eluser]the_unforgiven[/eluser]
I'm having a problem with pagination not counting the amount of records and not creating links correctly. My code is here -> http://pastie.org/8506894 Everything is within the function. It shows up the links but it's not limiting to the specific $limit I set. Really could do with some help on this please.
[eluser]sv3tli0[/eluser]
At the line where you count rows, is there a valid SQL because 'code' wont work ? Code: $rows = $this->db->count_all('code');
[eluser]the_unforgiven[/eluser]
Valid SQL i'm not sure I follow did you look at the pastie.org link?
[eluser]sv3tli0[/eluser]
Sorry, I am little sleepy let me be clear.. As I see at your code you are making 1 sql to catch data and second to catch count but with different WHERE clauses (first has few clauses and second counts all records).. This way you have for example: From 1st query you have 4 records with those where clauses. And 26 counted at second count because there aren't any WHERE's. Why you have comment the num_rows() ? Code: $config['total_rows'] = $rows; //$q->num_rows(); This is the second query which is completely different from your first one. Code: $rows = $this->db->count_all('code');
[eluser]the_unforgiven[/eluser]
Sleepy! Yeah me too was at this till 2:30am Because I was trying some more things out, what would be the best way to achieve pagination based on what you see in my code so far.?
[eluser]the_unforgiven[/eluser]
That doesn't work hence why I tried other queries
[eluser]sv3tli0[/eluser]
Add Code: $rows = $q->num_rows(); before Code: $codes = $q->result(); and use it For test echo it..
[eluser]the_unforgiven[/eluser]
Ok, not sure if that works because going to the next page which produces the URL of: Code: htp://localhost/admin/clients/reports/list_all/15 I have a route setup of: Code: $route['clients/reports/list_all'] = 'reports/list_all'; And I tried adding $route['clients/reports/list_all/(:any)'] = 'reports/list_all/$1'; but this doesn't do anything either!
[eluser]sv3tli0[/eluser]
not that you have set Code: $config['uri_segment'] = 3; While at > http://localhost/admin/clients/reports/list_all/15 segment is 5th doesn't matter which is your base_url What is your base_url ? |
Welcome Guest, Not a member yet? Register Sign In |