]> git.nbdom.net Git - nb.git/commitdiff
Fix nav when count < limit
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 6 Jan 2016 02:38:21 +0000 (02:38 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 6 Jan 2016 02:38:21 +0000 (02:38 +0000)
lib/php/db/table.php

index c0113f2d54514192b39da7f0186ffb5823a92076..20bbef3a717a17f6cfca9738221d8f653e220c0c 100644 (file)
@@ -363,6 +363,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
   function nav($count,$tot,$limit) {
 
     $html = '';
+
     if ($count<$tot) {
       list($x,$y) = strpos($limit,',')!==false
         ? preg_split('/\s*,\s*/',$limit)
@@ -373,6 +374,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
       $next = $x + $y;
 
       $this->debug("x=$x limit=$y prev=$prev next=$next tot=$tot",1);
+
     } else {
       $x = 0;
       $y = $tot;
@@ -384,7 +386,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
 
     if ($prev>=0) $html .= '<span class="prev"><a href="'.$this->url_list('limit',preg_replace('/^0,/','',"$prev,$y")).'">&lt;&lt;</a></span>&nbsp;';
 
-    $html .= '<span class="count">'.($tot ? ($x+1) : 0).' - '.($x+$y).' / '.$tot.' results</span>';
+    $html .= '<span class="count">'.($tot ? ($x+1) : 0).' - '.( $count<($x+$y) ? $count : ($x+$y) ).' / '.$tot.' results</span>';
 
     if ($next<$tot) $html .= '&nbsp;<span class="prev"><a href="'.$this->url_list('limit',"$next,$y").'">&gt;&gt;</a></span>';