Merge pull request 'pull request from SPM-Zayid-468 , Adding Filters On Course Search' (#38) from SPM-Zayid-468 into master
Reviewed-on: http://121.4.94.30:3000/mrlan/LRR/pulls/38Bug460-Malango
						commit
						b0f1f313d6
					
				
							
								
								
									
										14
									
								
								Courses.php
								
								
								
								
							
							
						
						
									
										14
									
								
								Courses.php
								
								
								
								
							|  | @ -552,27 +552,31 @@ if( $_SESSION['user_type']=="Student") | |||
| <?php  | ||||
|     error_reporting(0); | ||||
|     $student_id= $_SESSION['user_student_id']; | ||||
|     // current academic year - i.e 2021 - 2022 , so we will show in search result:
 | ||||
|     // course containing either 2021 or 2022 as academic year.
 | ||||
|     $oldest_academic_year = date('Y') - 1; | ||||
|     if(!empty($_GET["search"]) || !empty($_GET["faculty"])) | ||||
|     { | ||||
|         $search = trim(mysqli_real_escape_string($con, $_GET["search"])); | ||||
|         $faculty = mysqli_real_escape_string($con, $_GET["faculty"]); | ||||
|      | ||||
|         | ||||
|         // the user has not entered something under "Find course by Code"
 | ||||
|         if($faculty=="") | ||||
|         { | ||||
|             echo "<h4> Search Results for Course Code $search</h4><hr>"; | ||||
|             $result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`," | ||||
|                                    . " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members`  " | ||||
|                                    . " , users_table.Full_Name  FROM `courses_table` INNER JOIN users_table" | ||||
|                                    . " ON users_table.User_ID=courses_table.Lecturer_User_ID where Course_Code like '%{$search}%' and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id)"); | ||||
|                                    . " ON users_table.User_ID=courses_table.Lecturer_User_ID where Academic_Year >= $oldest_academic_year and Course_Code like '%{$search}%'  and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id) order by Academic_Year desc"); | ||||
|         }  | ||||
|         // the user has entered something under "Find course by Code"
 | ||||
|         else | ||||
|         { | ||||
|             echo "<h3> Find Courses under faculty $faculty</h3>"; | ||||
|             $result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`,
 | ||||
|        `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members`  | ||||
|          , users_table.Full_Name  FROM `courses_table` INNER JOIN users_table | ||||
|          ON users_table.User_ID=courses_table.Lecturer_User_ID where Faculty='$faculty'  and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id)");
 | ||||
|          ON users_table.User_ID=courses_table.Lecturer_User_ID where Academic_Year >= $oldest_academic_year  and Faculty='$faculty'  and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id) order by Academic_Year desc");
 | ||||
|         } | ||||
|       | ||||
| 
 | ||||
|  | @ -605,7 +609,7 @@ if( $_SESSION['user_type']=="Student") | |||
|             } | ||||
|         } | ||||
|     } | ||||
|       | ||||
|     // Otherwise, list the student's joined courses (already done), in reverse chronological order
 | ||||
|     echo "<h4> My Courses </h4>"; | ||||
|     $result = mysqli_query($con,"SELECT users_table.Full_Name, course_students_table.Status, courses_table.Course_ID, `Course_Name`, `Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` FROM `courses_table`
 | ||||
| INNER JOIN users_table | ||||
|  | @ -613,7 +617,7 @@ INNER JOIN users_table | |||
| 
 | ||||
| INNER JOIN course_students_table on course_students_table.Course_ID=courses_table.Course_ID | ||||
| 
 | ||||
|                   where course_students_table.Student_ID=$student_id");
 | ||||
|                   where course_students_table.Student_ID=$student_id order by Academic_Year desc");
 | ||||
|   | ||||
|     if(mysqli_num_rows($result)==0) | ||||
|     { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue