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

if(isset($_POST["countrymid"]) && !empty($_POST["countrymid"])){
    //Get all state data
	$countrymid=$_POST['countrymid'];
	
	
	
	 $eve="SELECT coursename,cnmid FROM res_coursename_master WHERE cnmid in (select cnmid from res_course_master where countrymid = $countrymid)";
	$re = mysqli_query($conn, $eve);

    //Count total number of rows
    if(mysqli_num_rows($re) > 0)
	{
		
		echo '<option value="All">All</option>';
        while($rt = mysqli_fetch_assoc($re))
		{
			/* $coursemid=$rt['coursemid'];
			$_SESSION['selectedcourse']=$coursemid; */
			$cnmid=$rt['cnmid'];
			
			$coursename=$rt['coursename'];
			
			if($_SESSION['cnmid'] == $cnmid)
			{
			
            echo '<option value="'.$cnmid.'" selected>'.$coursename.'</option>';
			}else{
				 echo '<option value="'.$cnmid.'">'.$coursename.'</option>';
			}
        }
    }else{
        echo '<option value="All">All </option>';
    }
}
?>
