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

            $tari_get_stored_instituion_id = $_POST['tari_get_stored_instituion_id'];
            $campus_id = $_POST['campus_id'];
            $classid = $_POST['classid'];


            $UserID = $_POST['UserID'];
            $UserType = $_POST['UserType'];


       

          if($UserType == 'teacher')
          {

                        $check_subject = ("SELECT DISTINCT `subjectorcourse`.`SubjectOrCourseID`, `subjectorcourse`.`SubjectOrCourseTitle` FROM `courseorsubjectallocation` 
                        INNER JOIN `subjectorcourse` INNER JOIN `classtemplate` ON `subjectorcourse`.ClassTemplateID = `classtemplate`.ClassTemplateID
                        ON `courseorsubjectallocation`.`SubjectOrCourseID` = `subjectorcourse`.`SubjectOrCourseID`  WHERE  `courseorsubjectallocation`.`CampusID`='$campus_id'
                        AND `courseorsubjectallocation`.`CourseOrSubjectTeacherUserID`='$UserID' AND `subjectorcourse`.ClassTemplateID='$classid'");

          }else
          {


                    $check_subject = ("SELECT DISTINCT `subjectorcourse`.`SubjectOrCourseID`, `subjectorcourse`.`SubjectOrCourseTitle` FROM `courseorsubjectallocation` 
                        INNER JOIN `subjectorcourse` INNER JOIN `classtemplate` ON `subjectorcourse`.ClassTemplateID = `classtemplate`.ClassTemplateID
                        ON `courseorsubjectallocation`.`SubjectOrCourseID` = `subjectorcourse`.`SubjectOrCourseID`  WHERE  `courseorsubjectallocation`.`CampusID`='$campus_id'
                        AND `subjectorcourse`.ClassTemplateID='$classid'");


          }
         

       


        $query_subject = mysqli_query($link,$check_subject);
        $fetch_subject = mysqli_fetch_assoc($query_subject);
        $row_subject = mysqli_num_rows($query_subject);

        if($row_subject > 0)
        {

            echo '<option value="NULL">Select Subject</option>';
           
                
            do{
                $ClassTemplateName = $fetch_subject['SubjectOrCourseTitle'];
                $ClassTemplateID = $fetch_subject['SubjectOrCourseID'];

                echo '<option value="'.$ClassTemplateID .'">'.$ClassTemplateName .'</option>';

            }while( $fetch_subject = mysqli_fetch_assoc($query_subject));

           

        }else{

            echo '<option value="NULL">No class found</option>';
            
        }
?>
