<?php
include_once 'connect.php';

$cons_id = $_POST['cons_id'];
$query = "SELECT uc_id AS id, uc_name FROM union_councils WHERE status = 1";
if ($cons_id) {
    $query .= " AND cons_id = $cons_id";
}
$query .= " ORDER BY uc_name ASC";

$result = $conn->query($query);
$options = "<option value=''>All Union Councils</option>";
while ($row = $result->fetch_assoc()) {
    $options .= "<option value='" . $row['id'] . "'>" . $row['uc_name'] . "</option>";
}
echo $options;
?>
