<?php
if(isset($_POST['state'])){
    require_once('../../assets/config/config.php');
    $obj=new Database();
    $id=$_POST['id'];

    if($_POST['state']=='csm'){
      $id="batch_no='".$id."'";
      $obj->select('students_course','*',null,$id,null,null);
      $result=$obj->getResult();
        $b[]=" ";                                
                  foreach($result as list("course_name"=>$batch))
                  {
                      array_push($b, $batch);
                  }
      
          header('Content-type:application/json');
          echo json_encode($b);
    }
    if($_POST['state']=='exm'){
      $id="course_name='".$id."'";
      $obj->select('exam','*',null,$id,null,null);
      $result=$obj->getResult();
        $b[]=" ";                                
                  foreach($result as list("exam_name"=>$batch))
                  {
                      array_push($b, $batch);
                  }
      
          header('Content-type:application/json');
          echo json_encode($b);
    }
    if($_POST['state']=='exm1'){
      $id="course_name='".$_POST['batch_no']."'";
      $obj->select('exam','*',null,$id,null,null);
      $result=$obj->getResult();
        $b[]=" ";                                
                  foreach($result as list("exam_name"=>$batch))
                  {
                      array_push($b, $batch);
                  }
      
          header('Content-type:application/json');
          echo json_encode($b);
    }
    if($_POST['state']=='exm2'){
      $id="exam_type='".$id."' and batch_no='".$_POST['batch_no']."'";
      $obj->select('student_exam','*',null,$id,null,null);
      $result=$obj->getResult();
        $b[]=" ";                                
                  foreach($result as list("id"=>$batch))
                  {
                      array_push($b, $batch);
                      
                  }
      
          header('Content-type:application/json');
          echo json_encode($b);
    }
    if($_POST['state']=='exm3'){
      $id="id='".$_POST['id']."'";
      $obj->select('student_exam','*',null,$id,null,null);
      $result=$obj->getResult();
      if($result)
      {
        header('Content-type:application/json');
        echo json_encode($result);
      }
      else
      {
        echo "0";
      }
    }
}
?>