From 54d1d5ee97216e71ac24e215db387a1c0ac3c0a1 Mon Sep 17 00:00:00 2001 From: Lan Hui Date: Thu, 7 Sep 2023 20:02:30 +0800 Subject: [PATCH] Courses.php: better code spacing (3) --- Courses.php | 76 +++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/Courses.php b/Courses.php index 7820623..e87c6fd 100644 --- a/Courses.php +++ b/Courses.php @@ -516,51 +516,47 @@ include 'Header.php'; $faculty = mysqli_real_escape_string($con, $_GET["faculty"]); // the user has not entered something under "Find course by Code" - if($search != "" && $faculty == "") - { + if ($search != "") { echo "

Search results for course code: $search


"; - $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 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 if ($faculty != "") - { - echo "

Find courses under faculty: $faculty

"; - $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 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"); + $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 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"); + } else if ($faculty != "") { // the user has entered something under "Find course by Code" + echo "

Find courses under faculty: $faculty

"; + $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 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"); } - - if(mysqli_num_rows($result)==0) - { - echo "No results.
"; - + if (mysqli_num_rows($result) == 0) { + echo "No results.
"; } else { + while($row = mysqli_fetch_assoc($result)) { + $name = $row['Course_Name']; + $code = $row['Course_Code']; + $faculty = $row['Faculty']; + $lecturer = $row['Full_Name']; + $academic = $row['Academic_Year']; + $url = $row['URL']; + $id = $row['Course_ID']; + $v = $row['Verify_New_Members']; + if($v > 0) { + $msg = " Lecturer verification required"; + $msg2 = "Send Joining Request"; + } - while($row = mysqli_fetch_assoc($result)) { - $name=$row['Course_Name']; - $code=$row['Course_Code']; - $faculty=$row['Faculty']; - $lecturer=$row['Full_Name']; - $academic=$row['Academic_Year']; - $url=$row['URL']; - $id=$row['Course_ID']; - $v=$row['Verify_New_Members']; - if($v>0) - { - $msg=" Lecturer verification required"; - $msg2="Send Joining Request"; - } - - echo "
- ($code) $name
($url)
Join -
Faculty: $faculty   Year: $academic   Lecturer: $lecturer
$msg
- "; - } + echo "
+ ($code) $name
($url)
+ Join
+ Faculty: $faculty   Year: $academic   Lecturer: $lecturer
+ $msg +
"; + } } } // Otherwise, list the student's joined courses (already done), in reverse chronological order