I want to order by highest numbers in variables, like in this image: https://ibb.co/CVh4n5L , how i can do it? Or if you have better solutions… Please explain and show me examples. Here is my code:
$num_a1 = $conn->query(‘SELECT COUNT(),a_topics.forum_id,a_forums.id,a_forums.parent_id,a_forums.gameid FROM a_topics JOIN a_forums ON a_topics.forum_id = a_forums.id WHERE a_forums.gameid = 63’)->fetchColumn();
$num_a2 = $conn->query('SELECT COUNT(),a_topics.forum_id,a_forums.id,a_forums.parent_id,a_forums.gameid FROM a_topics JOIN a_forums ON a_topics.forum_id = a_forums.id WHERE a_forums.gameid = 4’)->fetchColumn();
$stmt = $conn->prepare(‘SELECT id,name,parent_id,thisisgame,f_img FROM a_forums WHERE parent_id = 1 AND thisisgame = 1 GROUP BY id ORDER BY $num ? … ASC’);
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $row) {
echo “Name: $row[1] Topics:”;
switch (true) {
case $row[0] === ‘63’ :
echo “$num_a1”;
break;
case $row[0] === ‘4’ :
echo “$num_a2”;
break;
}