about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSebastian Korotkiewicz <skorotkiewicz@gmail.com>2022-03-25 03:21:25 +0100
committerSebastian Korotkiewicz <skorotkiewicz@gmail.com>2022-03-25 03:21:25 +0100
commitf1c5edbea66098708612855b5fc1fd424cb008e2 (patch)
tree80cc5e8b98dbf903d77d2ef749ff47c4330e9809
parentbf12d0faa1fb9468f48ebe1dd56223b24869f38f (diff)
downloadsite_roulette-f1c5edbea66098708612855b5fc1fd424cb008e2.tar.gz
fix previous button main
-rw-r--r--public_html/browser/get.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/public_html/browser/get.php b/public_html/browser/get.php
index fa346c3..9282263 100644
--- a/public_html/browser/get.php
+++ b/public_html/browser/get.php
@@ -15,13 +15,13 @@ if (isset($_GET["random"]) || !isset($member)) {
     $stmt->execute(array(':login_name' => $member));
     $row = $stmt->fetch(); // works
 
-    $stmt = $db->prepare("SELECT login_name FROM `websites` WHERE id > :id;");
+    $stmt = $db->prepare("SELECT login_name FROM `websites` WHERE id > :id ORDER BY id DESC LIMIT 1;");
     $stmt->execute(array(':id' => $row['id']));
     $next = $stmt->fetch(); // works
 
-    $stmt = $db->prepare("SELECT login_name FROM `websites` WHERE id < :id;");
+    $stmt = $db->prepare("SELECT login_name FROM `websites` WHERE id < :id ORDER BY id DESC LIMIT 1;");
     $stmt->execute(array(':id' => $row['id']));
-    $prev = $stmt->fetch(); // always return first record from database, why?
+    $prev = $stmt->fetch(); // works
 }
 
 $current = $row["login_name"];