<?php
$arr= array();
$parent_id= $_POST['parent_id'];
include("connect_db.php");
$uid = $_POST['uid'];
//$sql_fetch_zill= "SELECT * FROM area_masters WHERE super_id=0 and parent_id=$parent_id and parent_id<>'0' and status='active'";
$sql_fetch_zill = "SELECT DISTINCT u.taluka, m.* from area_masters as m join allotusers as u ON m.id = u.taluka WHERE status = 'active' AND u.user_id = '$uid' and u.jilla = '$parent_id'";
// echo $sql_fetch_zill;
// exit();
$res= mysqli_query($con,$sql_fetch_zill);
if($res){
    if(mysqli_num_rows($res)>0){
        $data['status']= "success";
        array_push($arr,$data);
        while($rows= mysqli_fetch_row($res)){
            $data['id']=$rows[0];
            $data['area_name']=$rows[2];
            $data['super_id']=$rows[3];
            $data['parent_id']=$rows[4];
            $data['status']=$rows[5];
            $data['created_at']=$rows[6];
            $data['updated_at']=$rows[7];
            array_push($arr,$data);
        }
    }
    else{
        $data['status']="fail";
        $data['message']="No data found";
        array_push($arr,$data);
    }
}
else{
    $data['status']="fail";
    $data['message']=mysqli_error($con);
    array_push($arr,$data);
}
echo json_encode($arr);
?>