<?php
// Include the database connection
include('db_connection.php');

// Function to get the count of pending friend requests
function getPendingFriendRequestsCount($student_id) {
    global $conn;

    $sql = "SELECT COUNT(*) AS request_count FROM student_requests WHERE requested_id = ? AND status = 'Pending'";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("i", $student_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $data = $result->fetch_assoc();

    return $data['request_count'];
}

// Function to get the count of unread messages
function getUnreadMessagesCount($student_id) {
    global $conn;

    $sql = "SELECT COUNT(*) AS message_count FROM student_messages WHERE receiver_id = ? AND status = 'Unread'";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("i", $student_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $data = $result->fetch_assoc();

    return $data['message_count'];
}
?>
