<?php
 error_reporting(E_ALL);
 ini_set('display_errors', 1);

 include('../../../config/config.php');

 $userID = $_POST["userID"];
 $campus = $_POST["campus"];

 $session = "SELECT * FROM `session` WHERE `sessionStatus` = 1";

 $ekeneselect = mysqli_query($link, $session);
 $ekene_get_select_details = mysqli_fetch_assoc($ekeneselect);
 $ekene_row_select = mysqli_num_rows($ekeneselect);

 $ekene_session_name = $ekene_get_select_details['sessionName'];



   $ekene_select_currentclass = "SELECT * FROM `classordepartmentstudentallocation` WHERE `CampusID` = '$campus' AND `Session` = '$ekene_session_name' AND `StudentID` = '$userID'";
   $ekene_query_link_classcurrent = mysqli_query($link, $ekene_select_currentclass);
   $ekene_get_details_currentclass = mysqli_fetch_assoc($ekene_query_link_classcurrent);
    $ekene_row_cnt_ekenecurrentclass = mysqli_num_rows($ekene_query_link_classcurrent);

    if ($ekene_row_cnt_ekenecurrentclass > 0)
    {
        $classid = $ekene_get_details_currentclass['ClassOrDepartmentID'];
    }
  
    

   

 $ekene_sql_class = (" SELECT *
 FROM courseorsubjectallocation
 INNER JOIN subjectorcourse ON courseorsubjectallocation.SubjectOrCourseID = subjectorcourse.SubjectOrCourseID
 WHERE courseorsubjectallocation.CampusID = '$campus' AND courseorsubjectallocation.ClassOrDepartmentID = '$classid'");
 $ekene_query_link_class = mysqli_query($link, $ekene_sql_class);
 $ekene_get_details_subject = mysqli_fetch_assoc($ekene_query_link_class);

 $ekene_row_cnt_ekene = mysqli_num_rows($ekene_query_link_class);

 echo '<option value="NULL">Select subject</option>';

 if($ekene_row_cnt_ekene > 0)
 {
    
     
     do{
        

         $ekene_subject_id = $ekene_get_details_subject['SubjectOrCourseID'];

         $ekene_subject = $ekene_get_details_subject['SubjectOrCourseTitle'];

         echo '<option value="'.$ekene_subject_id.'">'.$ekene_subject.'</option>';
         
     }while($ekene_get_details_subject = mysqli_fetch_assoc($ekene_query_link_class));
 }
 else{
     echo '<option value="NULL">No Records Found</option>';
 }
?>