diff options
Diffstat (limited to 'system/libraries/Pagination.php')
-rw-r--r-- | system/libraries/Pagination.php | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index a004419d6..c66d570cd 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -109,17 +109,6 @@ class CI_Pagination { // Calculate the total number of pages $num_pages = ceil($this->total_rows / $this->per_page); - /* - // Calculate the total number of pages - $num_pages = intval($this->total_rows / $this->per_page); - - // Use modulus to see if our division has a remainder. If so, add one to our page number. - if ($this->total_rows % $this->per_page) - { - $num_pages++; - } - */ - // Is there only one page? Hm... nothing more to do here then. if ($num_pages == 1) { @@ -138,6 +127,13 @@ class CI_Pagination { $this->cur_page = 0; } + // Is the page number beyond the result range? + // If so we show the last page + if ($this->cur_page > $this->total_rows) + { + $this->cur_page = ($num_pages - 1) * $this->per_page; + } + $uri_page_number = $this->cur_page; $this->cur_page = floor(($this->cur_page/$this->per_page) + 1); |