Skip to content
Advertisement

Php paging data count show up at each page

I want to show up paging data like Displaying 1 – 5 of 16 . I am trying to do this as below

JavaScript

But I am not getting proper result for this

Advertisement

Answer

You could have a negative value of $offset if ($page - 1).

You can juste remove it and it will work.

Code :

JavaScript
  • If pg is not defined, the result will be 0 - 3 of 20
  • If pg is 0, the result will be 0 - 3 of 20
  • If pg is 1 , the result will be 3 - 3 of 20
  • And so on…

Note that you should test if $page is lower than $number_of_pages to avoid to go to far, or lower than 0.

EDIT A more complete code :

JavaScript

Output :

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement