<?php
require_once __DIR__ . "/../../config/db.php";
header("Content-Type: application/json");

$district_id = $_GET["district_id"] ?? "";
if (!$district_id) {
    echo json_encode([]);
    exit;
}

$stmt = $pdo->prepare("SELECT id, name FROM blocks WHERE district_id = ? ORDER BY name");
$stmt->execute([$district_id]);
echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
