sending list_users in json

This commit is contained in:
Václav Šmejkal 2024-05-21 20:02:52 +02:00
parent fa48f58cf1
commit b1f345394e
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 14 additions and 3 deletions

View File

@ -20,7 +20,13 @@
url: "./res/forum/api/list_users.php",
success: function(result)
{
$("#left_panel").html(result);
let users = "";
for (let i in result.users)
{
users += "<div class=\"output\">" + result.users[i] + "</div>";
}
$("#left_panel").html(users);
}
});

View File

@ -18,7 +18,12 @@ if ($out -> num_rows != 1)
$out = $database -> query("SELECT username FROM user ORDER BY id ASC");
$output = array();
while ($res = $out -> fetch_assoc())
{
echo "<div class=\"output\">" . $res["username"] . "</div>";
}
array_push($output, $res["username"]);
}
header('Content-type: application/json');
echo json_encode(["users" => $output]);