<?php
include '../../db.php'; // Include your DB connection file

if (isset($_POST['state_id'])) {
    $state_id = mysqli_real_escape_string($con, $_POST['state_id']);

    $dist_sql = "SELECT distName, id FROM dist WHERE stateId = '$state_id' ORDER BY distName ASC";
    $dist_res = mysqli_query($con, $dist_sql);

    $options = "";
    while ($dist_row = mysqli_fetch_assoc($dist_res)) {
        $options .= "<option value='{$dist_row['distName']}' data-id='{$dist_row['id']}'>{$dist_row['distName']}</option>";
    }

    echo $options;
}
?>