From 061ce6fecc588f67472b93d02537c49f11712551 Mon Sep 17 00:00:00 2001 From: monica Date: Tue, 13 Jan 2015 12:07:09 +0000 Subject: [PATCH] Various fixes in pages() function. git-svn-id: http://voip.null.ro/svn/ansql/trunk@135 dbfed7de-b0aa-0410-b6a1-c7e608b77fc9 --- lib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib.php b/lib.php index 4662b6c..8ab280a 100644 --- a/lib.php +++ b/lib.php @@ -561,9 +561,9 @@ function pages($total = NULL, $params = array()) $sp += $limit; } } - $pg_nr = $page/$limit + 1; + $pg_nr = floor($page/$limit)+1; print ''.$pg_nr.'  '; - if (($page+$limit) <= $total) { + if (($page+$limit) < $total) { if($pg_nr >= 3) $stop_at = $pg_nr + 2; else @@ -583,6 +583,10 @@ function pages($total = NULL, $params = array()) $next5 = $page + $limit*5; $last_page = floor($total/$limit) * $limit; + if ($limit==1) + $last_page = $total - 1; + elseif (floor(($total/$limit))==$total/$limit) + $last_page = floor($total/$limit) * ($limit - 1); /* jump 5 pages */ if ($next5 < $last_page)