<?php
include('connect.php');

error_reporting(0);

if(isset($_POST["inqbranch"]) && !empty($_POST["inqbranch"])){
    //Get all state data
    
	$eve="SELECT * FROM res_user_master WHERE utype = 'counseller' and branchmid=".$_POST["inqbranch"];
	
    $re = mysqli_query($conn, $eve);
	//echo '<option value="0">'.$eve.'</option>';
    //Count total number of rows
	echo '<option value="0">Select Counsellor</option>';
    if(mysqli_num_rows($re) > 0)
	{
		
        while($rt = mysqli_fetch_assoc($re)){ 
		$umid= $rt['umid'];
		$eve1="SELECT * FROM res_inquiry_master WHERE ipcouncellor=$umid and imid=".$_POST["imid"];
	
    $re1 = mysqli_query($conn, $eve1);
	
	
    if(mysqli_num_rows($re1) > 0)
	{
            echo '<option value="'.$rt['umid'].'" selected>'.$rt['ufullname'].'</option>';
	}else{
		 echo '<option value="'.$rt['umid'].'" >'.$rt['ufullname'].'</option>';
	}
			
        }
    }else{
        echo '<option value="0">No Data Found1</option>'; 
    }
}else{
	echo '<option value="0">Select Counsellor</option>';
}
?>