<?php
        // where is your config file stored?
	include ("config.php");

	
	
	$Employee_ID = htmlspecialchars(trim($_POST['EmployeeID']));
	$HEmployeeID= htmlspecialchars(trim($_POST['HEmployeeID']));
	$Name = htmlspecialchars(trim($_POST['Name']));
	$Gender = htmlspecialchars(trim($_POST['Gender']));
	$Boarding_Point  = htmlspecialchars(trim($_POST['country']));
	$Telephone_No = htmlspecialchars(trim($_POST['TelephoneNo']));
	$Department  = htmlspecialchars(trim($_POST['Department']));
	$Bus_No= htmlspecialchars(trim($_POST['country_ID']));
	$ans='select StaffId from staff where EmployeeId="'.$HEmployeeID.'"';
	
	
    $result_disp = mysql_query($ans);
    $query_data = mysql_fetch_array($result_disp);
    $resu=$query_data['StaffId'];
	$checkbusquer='select BusNumber from stop where StopName="'.$Boarding_Point.'"';
	$ans=mysql_query($checkbusquer);
	$res=mysql_fetch_array($ans);
	if(mysql_num_rows($ans)<=0)
	{
	  echo "nobus";
	  exit();
	} 
	else
	{
		$Bus_No=$res['BusNumber'];
    } 
//echo $ans."<br>";


//    if(mysql_num_rows(mysql_query($ans))>0)
//      {
//	   echo "yes"; //Employee Number all ready exists
//	   }
//	else
//		{
//		echo "no"; //New Employee student details
		//now set the session from here if needed
		//$_SESSION['u_name']=$user_name; 
		// "INSERT INTO staff(EmployeeId,Name,Department,TeleNo,Gender,BusNumber,StopName) VALUES ('$Employee_ID','$Name','$Department','$Telephone_No','$Gender','$Bus_No','$Boarding_Point')";		
		
		$EditClient  ="update staff set EmployeeId='$Employee_ID',Name='$Name',Department='$Department',TeleNo='$Telephone_No',Gender='$Gender',BusNumber='$Bus_No',StopName='$Boarding_Point' where StaffId='$resu'";
		echo $EditClient."<br>";
		print_r($_POST);
    mysql_query($EditClient) or die(mysql_error());
	//}
	
	


?>