<?php

define('DB_SERVER', 'localhost');

define('DB_USERNAME', 'Restax_final');

define('DB_PASSWORD', 'Restax_final123');

define('DB_NAME', 'Restax_api_data'); 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);




$grade_course_id = $request->getAttribute('grade_course_id');
$course_id=$request->getParsedBody()['course_id'];
$dept_id=$request->getParsedBody()['dept_id'];
$level_id=$request->getParsedBody()['level_id'];
$type=$request->getParsedBody()['type'];

$sql12="SELECT * FROM grade_course WHERE course_id='$course_id' AND level_id='$level_id' AND dept_id='$dept_id' AND type='$type'";

$res12= $con->query($sql12);

if(mysqli_num_rows($res12) > 0)
{

$response2=array('status' => "true",'Message' => "Data Already Exits");

echo json_encode($response2);


}
else{
 	$sql= "UPDATE grade_course SET course_id='$course_id',dept_id='$dept_id',level_id='$level_id',type='$type' WHERE grade_course_id=$grade_course_id";

	$res= $con->query($sql);

	$data=array('type' =>$type, 'id' =>$grade_course_id);
 

	

	$response=array('status' => "true",'Message' => "Data updated successfully",'grade' => $data);

echo json_encode($response); 
}


?>