summaryrefslogtreecommitdiff
path: root/public/users.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/users.php')
-rw-r--r--public/users.php16
1 files changed, 5 insertions, 11 deletions
diff --git a/public/users.php b/public/users.php
index 06aa459..54c7aed 100644
--- a/public/users.php
+++ b/public/users.php
@@ -17,20 +17,14 @@ if ($id == "") {
$page = $_GET["p"] ?? "0";
$limit = 50;
$offset = $page * $limit;
- $search = $_GET["q"] ?? "";
+ $search = "%" . ($_GET["q"] ?? "") . "%";
$stmt = $db->prepare("SELECT id, username, joined_at, last_active_at
FROM users
- " . ($search != "" ? " WHERE username LIKE ? " : "") . "
+ WHERE username LIKE ?
ORDER BY last_active_at DESC LIMIT ? OFFSET ?");
- if ($search == "") {
- $stmt->bindParam(1, $limit, PDO::PARAM_INT);
- $stmt->bindParam(2, $offset, PDO::PARAM_INT);
- } else {
- $search = "%$search%";
- $stmt->bindParam(1, $search, PDO::PARAM_STR);
- $stmt->bindParam(2, $limit, PDO::PARAM_INT);
- $stmt->bindParam(3, $offset, PDO::PARAM_INT);
- }
+ $stmt->bindParam(1, $search, PDO::PARAM_STR);
+ $stmt->bindParam(2, $limit, PDO::PARAM_INT);
+ $stmt->bindParam(3, $offset, PDO::PARAM_INT);
$stmt->execute();
$all_user_count = $search ? $stmt->rowCount() : $db->query("SELECT COUNT(*) FROM users")->fetch()[0];