<?php
include 'db_connect.php'; // MySQL কানেকশন

$post_id = $_GET['post_id'];

$con = dbConnect();

$query = "SELECT 
            SUM(CASE WHEN reaction = 'like' THEN 1 ELSE 0 END) AS like_count,
            SUM(CASE WHEN reaction = 'dislike' THEN 1 ELSE 0 END) AS dislike_count 
          FROM post_reactions WHERE post_id = ?";

$stmt = $con->prepare($query);
$stmt->bind_param("i", $post_id);
$stmt->execute();
$result = $stmt->get_result();
$data = $result->fetch_assoc();

echo json_encode($data);
?>
