my_courses.php (1360B)
1 <html lang='en-CA'> 2 <h1>My Courses</h1> 3 <form class='action_form' id='my_courses_form' action=''> 4 <label for='course'>Course:</label><br> 5 6 <?php 7 session_start(); 8 9 $root = realpath($_SERVER['DOCUMENT_ROOT']); 10 include "$root/php/db.php"; 11 12 $db = database::get_connection(); 13 14 # Don't care about prepared statements here since no input 15 $stmt = "SELECT ID From Users WHERE UserName='$_SESSION[user]'"; 16 $query = $db->query($stmt); 17 $result = mysqli_fetch_assoc($query); 18 19 # Get courses taught by instructor 20 $stmt = "SELECT CourseCode, Section, Term, Year FROM Instructors WHERE FacultyID=$result[ID];"; 21 $query = $db->query($stmt); 22 while ($results[] = mysqli_fetch_object($query)); 23 array_pop($results); 24 ?> 25 26 <!--Show instructor's courses in drop-down--> 27 <select id='course' name='course'> 28 <?php foreach ( $results as $option ) : ?> 29 <option value="<?php echo "$option->CourseCode $option->Section $option->Term $option->Year"; ?>"><?php echo "$option->CourseCode$option->Section-$option->Term"; ?></option> 30 <?php endforeach; ?> 31 </select><br> 32 <input type='submit' value='Generate Class List'> 33 </form> 34 </html>