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

error_reporting(0);

if(isset($_POST["traningservicemid"]) && !empty($_POST["traningservicemid"])){
    //Get all state data
    
	$traningservicemid = $_POST['traningservicemid'];
	$tmmid = $_POST['tmmid'];
	
	
	echo $eve="SELECT * FROM res_traningsubservice_master WHERE traningservicemid= ".$traningservicemid;
	
    $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 subservice</option>';
        
		
		while($rt = mysqli_fetch_assoc($re)){
			$traningsubservicemid = $rt['traningsubservicemid'];
			$eve1 = "select traningsubservicemid from res_traningmodule_master where traningsubservicemid=$traningsubservicemid  and tmmid=$tmmid";
			$re1 = mysqli_query($conn, $eve1);
echo '<option value="'.$eve1.'">'.$eve1.'</option>';
    if(mysqli_num_rows($re1) > 0)
	
{
            echo '<option value="'.$rt['traningsubservicemid'].'" selected>'.$rt['traningsubservicename'].'</option>';
}else{
	 echo '<option value="'.$rt['traningsubservicemid'].'">'.$rt['traningsubservicename'].'</option>';
}
			
        }
    }else{
        echo '<option value="0">No Data Found</option>'; 
    }
}
?>