]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Working on display record management
authorJean-Marc Pigeon <jmp@safe.c>
Mon, 24 Nov 2025 14:56:02 +0000 (09:56 -0500)
committerJean-Marc Pigeon <jmp@safe.c>
Mon, 24 Nov 2025 14:56:02 +0000 (09:56 -0500)
www/gessql.php
www/lvlusr.php

index ca52def31f521f313bacd0203073fcf87d0ed5d1..cf60f6ae7ede6aa95e2ed0c9b609c7c60703748c 100644 (file)
@@ -97,7 +97,7 @@ class probe       {
     /**
      * Count total number of items matching the current WHERE conditions
      */
-    public function count(): int
+    public function getnumrec(): int
     {
         $sql = "SELECT COUNT(*) AS cnt FROM {$this->table}";
 
@@ -121,8 +121,9 @@ class probe       {
     public function goNext(): int
     {
         if ($this->limit !== null) {
-            $this->offset += $this->limit;
-        }
+          $last=max($this->getnumrec(),$this->limit);
+          $this->offset = min($last-$this->limit,$this->offset+$this->limit);
+          }
         return $this->offset;
     }
 
@@ -155,7 +156,7 @@ class probe       {
     public function goLast(): int
     {
         if ($this->limit !== null) {
-            $total = $this->count();
+            $total = $this->getnumrec();
             $this->offset = max(0, $total - $this->limit);
         }
         return $this->offset;
index 230b58e8e21d354c776ddb143ebdb2b07199ab50..9ef1cb683c6bfeffd5eccc2a6da921b03e7196a1 100644 (file)
@@ -98,7 +98,7 @@ if (isset($_POST['username'])) {
   $username=trim(($_POST['username']));
   $rqst->where("email","like","%$username%");
   }
-$numrec=$rqst->count();
+$numrec=$rqst->getnumrec();
 if (isset($_POST['scanner'])) {
   $scanner=$_POST['scanner'];
   switch ($scanner) {