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

error_reporting(0);

if(isset($_POST["stiqmid"]) && !empty($_POST["stiqmid"])){
    //Get all state data
    
	$stiqmid = $_POST['stiqmid'];
	 $eve1 = "SELECT * FROM res_studentinquiry_detail WHERE stiqmid= '$stiqmid'";
	  $re1 = mysqli_query($conn, $eve1);
	
    //Count total number of rows
     if(mysqli_num_rows($re1) > 0)
	{
		
        while($rt1= mysqli_fetch_assoc($re1))
		{ 
			$siprefferedcountry=$rt1['siprefferedcountry'];
		}  
	}
	
	/* $eve2 = "SELECT * FROM res_studentinquiry_detail WHERE countrymid= '$stiqmid'";
	  $re2 = mysqli_query($conn, $eve2);
	
    //Count total number of rows
     if(mysqli_num_rows($re2) > 0)
	{
		
        while($rt2= mysqli_fetch_assoc($re2))
		{ 
			$siprefferedcountry=$rt2['siprefferedcountry'];
		}  
	} */
	
	$eve="SELECT * FROM res_countrydocument_detail WHERE countrymid= ".$siprefferedcountry;
	
    $re = mysqli_query($conn, $eve);
	//echo '<option value="'.$eve.'">'.$eve.'</option>';
    //Count total number of rows
    if(mysqli_num_rows($re) > 0)
	{
		while($rt= mysqli_fetch_assoc($re))
		{ 
			$documentmid=$rt['documentmid'];
		 
		  $eve2 = "SELECT * FROM res_inquirydocs_master WHERE idmid= '$documentmid'";
	  $re2 = mysqli_query($conn, $eve2);
	  //echo '<option value="'.$eve.'">'.$eve2.'</option>';
	
    //Count total number of rows
     if(mysqli_num_rows($re2) > 0)
	{
		
        while($rt2= mysqli_fetch_assoc($re2))
		{ 
			$idmname=$rt2['idmname'];
		}  
	} 
		
       
            echo '<option value="'.$documentmid.'">'.$idmname.'</option>';
			
        }
    }else{
        echo '<option value="0">No Data Found2</option>'; 
    }
	}

?>