<?php

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


$course_id=$request->getParsedBody()['course_id'];
 $season_id = $request->getParsedBody()['season_id'];
  $exams_id = $request->getParsedBody()['exams_id'];
  $paper = $request->getParsedBody()['paper'];
  $maxmarks=$request->getParsedBody()['max_marks'];
  $minmarks = $request->getParsedBody()['min_marks'];
 $response=array();
 $data=array();

$sqll="(SELECT * FROM set_marks WHERE exams_id='$exams_id' AND max_marks='$maxmarks' AND paper='$paper' AND min_marks='$minmarks')";
$res= $con->query($sqll);
if($res->num_rows>0)
{
$response1=array('status' => "true",'Message' => "data already exist");
echo json_encode($response1);
}

else{

  $sql="INSERT INTO set_marks (course_id,season_id,exams_id,paper,max_marks,min_marks) VALUES ($course_id,$season_id,$exams_id,$paper,$maxmarks,$minmarks)";
$res=mysqli_query($con,$sql);
if ($res=true) {
     // $data=
     //    array(
     //      "Exam_id"=>$exams_id,
     //     );
    
    $message=$data;

$response=array('status' => "true",'Message' => "SetMarks Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "SetMarks Failed");
         echo json_encode($response);
        }
}
?>