Fixed paging
authorAndrew DeFaria <Andrew@DeFaria.com>
Fri, 24 Nov 2017 18:38:55 +0000 (10:38 -0800)
committerAndrew DeFaria <Andrew@DeFaria.com>
Fri, 24 Nov 2017 18:38:55 +0000 (10:38 -0800)
maps/JavaScript/ListActions.js
maps/php/list.php

index 7918f46..3920de2 100644 (file)
@@ -127,6 +127,6 @@ function CheckEntry (form) {
 } // CheckEntry
 
 function ChangePage (page, type, lines) {
-  window.location = "/maps/php/list.php" + "?type=" + type + "&next=" + page * lines;
+  window.location = "/maps/php/list.php" + "?type=" + type + "&next=" + (page - 1) * lines;
 } // ChangePage
 
index 7cca7b2..81d65ed 100755 (executable)
@@ -49,7 +49,7 @@ if (($next - $lines) > 0) {
 
 $total = CountList ($type);
 $last = $next + $lines < $total ? $next + $lines : $total;
-$last_page = floor ($total / $lines);
+$last_page = floor ($total / $lines) + 1;
 $this_page = $next / $lines + 1;
 ?>
 </head>
@@ -73,15 +73,16 @@ $this_page = $next / $lines + 1;
     print "<input type=hidden name=next value=$next>";
     print "Page: <select name=page onChange=\"ChangePage(this.value,'$type','$lines');\"";
     for ($i = 0; $i <= $last_page; $i++) {
-      if ($i == ($this_page - 1)) {
+      if ($i == ($this_page)) {
         print "<option selected>$i</option>";
       } else {
         print "<option>$i</option>";
       } // if
     } // for
     print "</select>";
+    //print "next: $next last_page: $last_page";
     print "&nbsp;of <a href=\"/maps/php/list.php?type=$type&next=" . 
-          $last_page * $lines . "\">$last_page</a>";
+          ($last_page - 1) * $lines . "\">$last_page</a>";
   ?>
   </div>
   <div class="toolbar" align="center">