<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: Content-Type");

require_once 'config.php'; // Include the database configuration

$conn = getDbConnection(); // Connect to the database

$query = "SELECT id, house_number, alert_numbers FROM houses";
$result = $conn->query($query);

if ($result && $result->num_rows > 0) {
    $houses = array();

    while ($row = $result->fetch_assoc()) {
        $houses[] = $row;
    }

    echo json_encode(array("status" => "success", "houses" => $houses));
} else {
    echo json_encode(array("status" => "error", "message" => "No houses found"));
}

$conn->close();
?>

