<?php
include 'confing.php';


if (isset($_GET['user_id'])) {
    $user_id = $_GET['user_id'];

    $sql = "SELECT vehicle_type, share_location, alternate_no, apartment, block, user_id, type, trakername 
            FROM generat_qr 
            WHERE user_id = '$user_id' AND type = 'Home'";

    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        $data = array();
        while($row = $result->fetch_assoc()) {
            $data[] = $row;
        }
        echo json_encode($data);
    } else {
        echo json_encode(array("message" => "No data found"));
    }
} else {
    echo json_encode(array("message" => "user_id is required"));
}

$conn->close();
?>
