<?php


 error_reporting(E_ALL);
 ini_set('display_errors', 1);

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

  $userID = $_POST["userID"];
  $campus = $_POST["campus"];
  
  $usertype = $_POST["usertype"];
  
  
  if($usertype == 'teacher')
  {
      
                  $ekene_sql_class = "SELECT DISTINCT `subjectorcourse`.`SubjectOrCourseID`, `subjectorcourse`.SubjectOrCourseTitle
             FROM `subjectorcourse`
             INNER JOIN `courseorsubjectallocation` 
                 ON `courseorsubjectallocation`.`SubjectOrCourseID` = `subjectorcourse`.`SubjectOrCourseID`
             WHERE 
                 `courseorsubjectallocation`.`CampusID` = '$campus' 
                 AND `courseorsubjectallocation`.CourseOrSubjectTeacherUserID = '$userID'
             ORDER BY `subjectorcourse`.`SubjectOrCourseTitle` ASC
            ";
      
  }else
  {
      
      
                  $ekene_sql_class = "SELECT DISTINCT `subjectorcourse`.`SubjectOrCourseID`, `subjectorcourse`.SubjectOrCourseTitle
             FROM `subjectorcourse`
             INNER JOIN `courseorsubjectallocation` 
                 ON `courseorsubjectallocation`.`SubjectOrCourseID` = `subjectorcourse`.`SubjectOrCourseID`
             WHERE 
                 `courseorsubjectallocation`.`CampusID` = '$campus' 
                 
             ORDER BY `subjectorcourse`.`SubjectOrCourseTitle` ASC
            ";
                  
  }

 
 

 $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  mysqli_error($link);

 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>';
 }
?>