From 4e6193e82532967ff7159c91050a6bf33dceab1a Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 22 Apr 2025 17:24:24 +0500 Subject: upd: show all user's reactions --- public/users.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'public/users.php') diff --git a/public/users.php b/public/users.php index 54c7aed..2de3ed2 100644 --- a/public/users.php +++ b/public/users.php @@ -193,15 +193,11 @@ $contributions += intval($stmt->fetch()[0]); // getting status $status = 1; -// getting favorite reaction -$fav_reaction = null; - -$stmt = $db->prepare("SELECT rate, COUNT(*) AS c FROM ratings WHERE user_id = ? GROUP BY rate ORDER BY c DESC LIMIT 1"); +// getting reactions +$stmt = $db->prepare("SELECT rate, COUNT(*) AS c FROM ratings WHERE user_id = ? GROUP BY rate ORDER BY c DESC"); $stmt->execute([$user->id()]); -if ($row = $stmt->fetch()) { - $fav_reaction = $row; -} +$fav_reactions = $stmt->fetchAll(PDO::FETCH_ASSOC); // getting favorite emote $fav_emote = 1; @@ -295,12 +291,14 @@ if ($is_json) { + if ($fav_reactions != null) { ?> - Favorite reaction + Reactions '; + foreach ($fav_reactions as $reaction) { + echo $reaction["c"] . ' ' . RATING_NAMES[$reaction['; + } ?>