<?php
$con = mysqli_connect(localhost, Restax_final, Restax_final123, Restax_api_data);     
$set_papers_id=$request->getParsedBody()['set_papers_id'];
 $units=$request->getParsedBody()['units'];
  $course_id=$request->getParsedBody()['course_id'];
   $season_id=$request->getParsedBody()['season_id'];
    $exams_id=$request->getParsedBody()['exams_id'];
    $slots=$request->getParsedBody()['slots'];
$units_data = json_encode($units);
		
$response=array();

$select_sql = "SELECT * FROM set_syllabus WHERE paper = '$set_papers_id'";

$result_data = $con->query($select_sql);
if(!$result_data->num_rows>0){
    

	// $sql= "UPDATE set_grade SET range_in='$range_in',grade='$grade',start_module='$start_module' WHERE course_id='$course_id'AND dept_id='$dept_id'AND level_id='$level_id'";

$sql="INSERT INTO set_syllabus (course_id,season_id,exams_id,paper,slots,paper_name) VALUES ('$course_id','$season_id','$exams_id','$set_papers_id','$slots','$units_data')";


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

	$data=array('name' =>$grade, );


	    // $message=$data;

		

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

echo json_encode($response);
}
else
{

	$response=array('status' => "true",'Message' => "Data already Inserted",$data);

echo json_encode($response);
}




?>