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

if(isset($_POST["ptype"]) && !empty($_POST["ptype"])){
    //Get all state data
	$ptype=$_POST['ptype'];
	//$ptype='Country';
	
	$stiqmid=$_POST['stiqmid'];
	//$stiqmid=12;
	
	
	$eve1 = "select res_studentinquiry_detail.siprefferedcountry,res_studentinquiry_detail.siprefferedsubservice,res_inquiry_master.inqbranch from res_inquiry_master,res_studentinquiry_detail where res_studentinquiry_detail.imid = res_inquiry_master.imid and res_studentinquiry_detail.stiqmid = $stiqmid";
	$re1 = mysqli_query($conn, $eve1);
	  if(mysqli_num_rows($re1) > 0)
	{
		
        while($rt1 = mysqli_fetch_assoc($re1))
		{
			$siprefferedcountry = $rt1['siprefferedcountry'];
			$inqbranch = $rt1['inqbranch'];
			$siprefferedsubservice = $rt1['siprefferedsubservice'];
		}
	}
	
	
	
	if($ptype == 'Service'){
		$eve = "select * from res_package_master where (countrymid=$siprefferedcountry or countrymid=0) and subservicemid=$siprefferedsubservice and ptype='Service'";
		
		
	}else if($ptype == 'Branch')
	{
		 $eve = "select * from res_package_master where branchmid=$inqbranch and ptype='Branch'";
		
	}
	$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</option>';
        while($rt = mysqli_fetch_assoc($re))
		{
			/* $coursemid=$rt['coursemid'];
			$_SESSION['selectedcourse']=$coursemid; */
			$packagemid=$rt['packagemid'];
			
			$packagename=$rt['packagename'];
			
            echo '<option value="'.$packagemid.'">'.$packagename.'</option>';
        }
    }else{
        echo '<option value="0">Select </option>';
    }
}
?>
