<?php 
// Include the database config file 
include_once 'config.php'; 
 
if(!empty($_POST["municipality"])){ 
    // Fetch state data based on the specific country 
    $query = "SELECT brgy FROM tb_region_directory WHERE municipality = '".$_POST['municipality']."' ORDER BY brgy ASC"; 
    $result = $con->query($query); 
     
    // Generate HTML of state options list 
    if($result->num_rows > 0){ 
        echo '<option value="">Select Barangay</option>'; 
        while($row = $result->fetch_assoc()){  
            echo '<option value="'.$row['brgy'].'">'.$row['brgy'].'</option>'; 
        } 
    }else{ 
        echo '<option value="">Barangay not available</option>'; 
    } 
} 
?>