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

if(isset($_POST["ipbirthcountry"]) && !empty($_POST["ipbirthcountry"])){
    //Get all state data
    
	$country = $_POST['ipbirthcountry'];
	 $eve1 = "SELECT * FROM res_country_master WHERE countryname= '$country'";
	  $re1 = mysqli_query($conn, $eve1);
	
    //Count total number of rows
     if(mysqli_num_rows($re1) > 0)
	{
		
        while($rt1= mysqli_fetch_assoc($re1))
		{ 
			$countrymid=$rt1['countrymid'];
		}  
	}
	
	$eve="SELECT * FROM res_state_master WHERE countrymid= ".$countrymid;
	
    $re = mysqli_query($conn, $eve);
	//echo '<option value="'.$eve.'">'.$eve.'</option>';
    //Count total number of rows
    if(mysqli_num_rows($re) > 0)
	{
		echo '<option value="0">Select State</option>';
        while($rt = mysqli_fetch_assoc($re)){ 
            echo '<option value="'.$rt['statename'].'">'.$rt['statename'].'</option>';
			
        }
    }else{
        echo '<option value="0">No Data Found</option>'; 
    }
}
?>