diff --git a/res/forum/admin.html b/res/forum/admin.html index 13cb259..d07287f 100644 --- a/res/forum/admin.html +++ b/res/forum/admin.html @@ -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 += "
" + result.users[i] + "
"; + } + + $("#left_panel").html(users); } }); diff --git a/res/forum/api/list_users.php b/res/forum/api/list_users.php index d356855..a6ab2d5 100644 --- a/res/forum/api/list_users.php +++ b/res/forum/api/list_users.php @@ -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 "
" . $res["username"] . "
"; -} \ No newline at end of file + array_push($output, $res["username"]); +} + +header('Content-type: application/json'); +echo json_encode(["users" => $output]); \ No newline at end of file