Courses.php: better code spacing (3)

Bug430-Eden2
Lan Hui 2023-09-07 20:02:30 +08:00
parent 1cac6bebea
commit 54d1d5ee97
1 changed files with 36 additions and 40 deletions

View File

@ -516,51 +516,47 @@ include 'Header.php';
$faculty = mysqli_real_escape_string($con, $_GET["faculty"]); $faculty = mysqli_real_escape_string($con, $_GET["faculty"]);
// the user has not entered something under "Find course by Code" // the user has not entered something under "Find course by Code"
if($search != "" && $faculty == "") if ($search != "") {
{
echo "<h4>Search results for course code: $search </h4><hr>"; echo "<h4>Search results for course code: $search </h4><hr>";
$result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `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
. " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` " FROM courses_table
. " , users_table.Full_Name FROM `courses_table` INNER JOIN users_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"); 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
// the user has entered something under "Find course by Code" (SELECT course_id FROM course_students_table WHERE Student_ID=$student_id) ORDER BY Academic_Year DESC");
else if ($faculty != "") } else if ($faculty != "") { // the user has entered something under "Find course by Code"
{ echo "<h3> Find courses under faculty: $faculty</h3>";
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
$result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, FROM courses_table
`Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` INNER JOIN users_table ON users_table.User_ID=courses_table.Lecturer_User_ID
, users_table.Full_Name FROM `courses_table` INNER JOIN users_table WHERE Academic_Year >= $oldest_academic_year AND Faculty='$faculty' AND courses_table.Course_ID NOT IN
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"); (SELECT course_id FROM course_students_table WHERE Student_ID=$student_id) ORDER BY Academic_Year DESC");
} }
if (mysqli_num_rows($result) == 0) {
if(mysqli_num_rows($result)==0) echo "No results. <hr>";
{
echo "No results. <hr>";
} else { } 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 = "<i class='fa fa-exclamation-circle'></i> Lecturer verification required";
$msg2 = "Send Joining Request";
}
while($row = mysqli_fetch_assoc($result)) { echo "<div class='btn btn-default' style='word-wrap:break-word'>
$name=$row['Course_Name']; ($code) $name <br>($url) <br>
$code=$row['Course_Code']; <a href='~\..\Script.php?JoinCourse=y&id=$id&std=$student_id&joining=$v' class='btn btn-sm btn-success' onclick=return confirm(\"Are you sure to join this course?\")' >Join</a> <br>
$faculty=$row['Faculty']; <span style='font-size:10pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span><br>
$lecturer=$row['Full_Name']; $msg
$academic=$row['Academic_Year']; </div>";
$url=$row['URL']; }
$id=$row['Course_ID'];
$v=$row['Verify_New_Members'];
if($v>0)
{
$msg="<i class='fa fa-exclamation-circle'></i> Lecturer verification required";
$msg2="Send Joining Request";
}
echo "<div class='btn btn-default' style='word-wrap:break-word'>
($code) $name <br>($url) <br> <a href='~\..\Script.php?JoinCourse=y&id=$id&std=$student_id&joining=$v' class='btn btn-sm btn-success' onclick=return confirm(\"Are you sure to join this course?\")' >Join</a>
<br> <span style='font-size:10pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span><br>$msg</div>
";
}
} }
} }
// Otherwise, list the student's joined courses (already done), in reverse chronological order // Otherwise, list the student's joined courses (already done), in reverse chronological order