From 435dcb3088ea07de1706a438241fc7938803dec0 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 24 May 2024 19:52:19 +0200 Subject: [PATCH] adding username to get_posts api response --- res/forum/api/get_posts.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/res/forum/api/get_posts.php b/res/forum/api/get_posts.php index d9b14a6..a1a63f5 100644 --- a/res/forum/api/get_posts.php +++ b/res/forum/api/get_posts.php @@ -28,6 +28,15 @@ while (($res = $out -> fetch_assoc())) $buffer_array[$key] = $value; } + $author_buffer = $database -> query("SELECT username FROM user WHERE id=" . $value); + if ($author_buffer -> num_rows == 1) + { + $buffer_array["username"] = ($author_buffer -> fetch_assoc())["username"]; + } else + { + $buffer_array["username"] = "[odstraněn]"; + } + array_push($output, $buffer_array); }