<?php session_start();
include("../connect.php");

if(isset($_SESSION['lasuadmincoursereg_id'])){
$ddd=mysqli_query($con,"select * from admin where id='".$_SESSION['lasuadmincoursereg_id']."'");
$adm=mysqli_fetch_assoc($ddd);

}


if(isset($_POST['find_matric_no']) && isset($_POST['find_programme'])){
	
$pro=explode("_",$_POST['find_programme']);
	
$dim=mysqli_query($con,"select * from student where matric_no='".$_POST['find_matric_no']."' AND programme_id='".$pro[0]."'");
if(mysqli_num_rows($dim)==1){
	
$stu=mysqli_fetch_assoc($dim);

$vay=mysqli_query($con,"select * from department where id='".$stu['dept_id']."'");
$dep=mysqli_fetch_assoc($vay);

echo ucwords($stu['sname'].' '.$stu['mname'].' '.$stu['fname']).'_'.$dep['department'];

}else{
	
echo 'No result found!_No result found!';
	
}
}



if(isset($_POST['find_course']) && isset($_POST['find_prog'])){
	
	
$pro=explode("_",$_POST['find_prog']);
	
$dim=mysqli_query($con,"select * from student where matric_no='".$_POST['find_course']."' AND programme_id='".$pro[0]."'");
if(mysqli_num_rows($dim)==1){	
$stu=mysqli_fetch_assoc($dim);

$svm=mysqli_query($con,"select * from semester where programme_id='".$stu['programme_id']."' AND (registration_control=1 OR add_delete_control=1) AND session !=''");

if(mysqli_num_rows($svm)>0){
$sxm=mysqli_fetch_assoc($svm);

$mec=mysqli_query($con,"select * from course where programme_id='".$stu['programme_id']."' AND dep_id='".$stu['dept_id']."' AND semester_id='".$sxm['id']."' order by course_code asc");

if(mysqli_num_rows($mec)>0){
	
	echo '<div class="form-group course_result">
								<label class="control-label mb-5" for="email_de">Select Course</label>
						<select class="form-control select2 add_course" name="a_course" required >
						<option value="" style="text-align:center;">Choose Course</option>';
							
							while($ele=mysqli_fetch_assoc($mec)){
	echo '<option value="'.$ele['id'].'">'.strtoupper($ele['course_code'].' ('.$ele['description']).') ::: '.$ele['unit'].'Units</option>';
							}
							
						echo '</select></div>';
	 }else{
		 
	echo '<div class="form-group course_result">
								<label class="control-label mb-5" for="email_de">Course</label>
						<select class="form-control" required >
						<option value="" style="text-align:center;">No Course Found!</option>
						</select>
												</div>';
}
}else{
	echo '<div class="form-group course_result">
								<label class="control-label mb-5" for="email_de">Course</label>
						<select class="form-control" required >
						<option value="" style="text-align:center;">Registration and Add/Delete Portal are closed!</option>
						</select>
												</div>';
}
}else{
	
echo '<div class="form-group course_result">
								<label class="control-label mb-5" for="email_de">Course</label>
						<select class="form-control" required >
						<option value="" style="text-align:center;">----</option>
						</select>
												</div>';
	
}
	
	
}













?>


 
 
	
		
		
		
		
		
		