Php
function studentSectionAvailableList($studentId, $currentSemester) { global $conn; $sql="SELECT s.section_id, c.course_code, c.course_name, s.section_number". "FROM Section s, Course c ". "WHERE s.section_id NOT IN ( SELECT s.section_id ". "FROM Student_Section ss, Section s ". " WHERE ss.section_id = s.section_id ". " AND ss.student_id = 's001')". AND s.course_code IN ( "SELECT s.course_code ". "FROM Student_Section ss, Section s ". " WHERE ss.section_id = s.section_id". " AND ss.student_id = 's001')". "AND s.course_code = c.course_code". "AND s.semester_id = 53"; $result = mysqli_query($conn,$sql) or die("Error in query: $query". mysqli_error($conn)); while(($section = mysqli_fetch_assoc($result))) { $sid = $section['section_id']; $cc = $section['course_code']; $cn = $section['course_name']; $sn = $section['section_number']; echo "<option value='$sid'>$cc - $cn (# $sn)</option>"; }