<?php
include "../db_connect.php";

$user_id = $_POST['user_id']; // লগইন করা ইউজারের আইডি
$con = dbConnect();

$response = [
    "followers_count" => 0,
    "following_count" => 0
];

// তাকে কয়জন ফলো করেছে (followers)
$followers_sql = "SELECT COUNT(*) AS followers_count FROM followers WHERE following_id = ?";
$stmt1 = $con->prepare($followers_sql);
$stmt1->bind_param("i", $user_id);
$stmt1->execute();
$result1 = $stmt1->get_result();
if ($row = $result1->fetch_assoc()) {
    $response["followers_count"] = $row["followers_count"];
}

// সে কাকে ফলো করছে (following)
$following_sql = "SELECT COUNT(*) AS following_count FROM followers WHERE follower_id = ?";
$stmt2 = $con->prepare($following_sql);
$stmt2->bind_param("i", $user_id);
$stmt2->execute();
$result2 = $stmt2->get_result();
if ($row = $result2->fetch_assoc()) {
    $response["following_count"] = $row["following_count"];
}

echo json_encode($response);
?>
