<?php
include("../config/db.php");

$district = $_GET['district'];

// join blocks + districts
$query = $conn->query("
    SELECT blocks.* FROM blocks
    LEFT JOIN districts ON blocks.district_id = districts.id
    WHERE districts.name = '$district'
");

echo '<option value="">-- Select Block --</option>';

while($row = $query->fetch_assoc()) {
    echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}