diff --git a/public/news.php b/public/news.php index 36666af8..ee0ccb62 100644 --- a/public/news.php +++ b/public/news.php @@ -90,7 +90,12 @@ if ($categoryId !== null) { p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, c.`category_id`, c.`category_name`, u.`user_id`, u.`username`, - COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour` + COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`, + ( + SELECT COUNT(`comment_id`) + FROM `msz_comments_posts` + WHERE `category_id` = `comment_section_id` + ) as `post_comments` FROM `msz_news_posts` as p LEFT JOIN `msz_news_categories` as c ON p.`category_id` = c.`category_id` @@ -156,7 +161,12 @@ $getPosts = Database::prepare(' p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, c.`category_id`, c.`category_name`, u.`user_id`, u.`username`, - COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour` + COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`, + ( + SELECT COUNT(`comment_id`) + FROM `msz_comments_posts` + WHERE `category_id` = `comment_section_id` + ) as `post_comments` FROM `msz_news_posts` as p LEFT JOIN `msz_news_categories` as c ON p.`category_id` = c.`category_id`