<?PHP
	// Retrieving values from textboxes
	include './conn.php';

	session_start();
	$staff_id = $_GET['staff_id'];
	

		
	// Sql query
	$sql1 = "SELECT user_id FROM lms.login WHERE user_type = 'PC'";
	$sql2 = "UPDATE lms.login SET user_type = 'PC' WHERE user_id = '".$staff_id."'";
	
	
	// Firing query
	$result = mysqli_query($conn,$sql1) or die(mysqli_error($conn));
	while($row = mysqli_fetch_array($result))
	{
		$previous_pc = $row['user_id'];
	}
	$sql3 = "UPDATE lms.login SET user_type = 'Staff' WHERE user_id = '".$previous_pc."'";
	mysqli_query($conn,$sql3) or die(mysqli_error($conn));
	mysqli_query($conn,$sql2) or die(mysqli_error($conn));
	
	// Printing nuber of rows affected
	
	
	echo 	"<script>
					alert(\"Program Coordinator Assigned Successfully.\");
				window.location=\"search_staff_to_assign_pc.php\";</script>";
	// Closing Connection
	mysqli_close($conn);
	
	
?>