From b84f7c03473f271ca53c80f9cb0f4b28755bb2cf Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 27 Oct 2006 03:11:11 +0000 Subject: --- system/libraries/Pagination.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'system/libraries/Pagination.php') 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); -- cgit v1.2.3-24-g4f1b