<?php
header('Content-Type: application/json');

$userId = $_GET['user_id'];

include 'db.php';

$sql = "SELECT COUNT(*) AS ongoing_count FROM new_trip_booking WHERE user_id = ? AND status NOT IN ('completed', 'cancelled')";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $userId);
$stmt->execute();
$result = $stmt->get_result();
$data = $result->fetch_assoc();

$stmt->close();
$conn->close();

echo json_encode(['ongoing_count' => $data['ongoing_count']]);
?>
