first; } public function getLast() { return $this->last; } public function getSubject() { return $this->subject; } } $teacherId = filter_input(INPUT_POST, 'id'); if ($teacherId == 0) return; try { // Connect to the database. $con = new PDO("mysql:host=localhost;dbname=school", "root", "sesame"); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Prepared statement query. $query = "SELECT student.first, student.last, subject ". "FROM student, class, student_class ". "WHERE teacher_id = :teacher_id ". "AND code = class_code ". "AND student.id = student_id ". "ORDER BY subject, student.last"; $ps = $con->prepare($query); $ps->bindParam(':teacher_id', $teacherId); $ps->execute(); createTable($ps); } catch(PDOException $ex) { print 'ERROR: '.$ex->getMessage(); } catch(Exception $ex) { print 'ERROR: '.$ex->getMessage(); } function createTable(PDOStatement $ps) { print "