Pagination issue

I'm having a problem with pagination not counting the amount of records and not creating links correctly.

My code is here ->

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. Smile

At the line where you count rows, is there a valid SQL because 'code' wont work Smile?
$rows = $this->db->count_all('code');

Valid SQL i'm not sure I follow did you look at the link?

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() ?
$config['total_rows'] =  $rows; //$q->num_rows();

This is the second query which is completely different from your first one.
$rows = $this->db->count_all('code');

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.?

Just use the > $q->num_rows()

That doesn't work hence why I tried other queries

$rows = $q->num_rows();

$codes = $q->result();

and use it

For test echo it..

Ok, not sure if that works because going to the next page which produces the URL of:

I have a route setup of:
$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!

not that you have set
$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 ?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.