In this section, we will build the screen that would retrieve all the current registrations in our course_registry
database. We will begin by adding the get
action to our StudentsCourses
controller that will use the getStudentsCourses
method provided by the StudentCourses
model. Once the data is retrieved from the getStudentsCourses
method, the data is forwarded to the get.php
view from our get
action. Let us add these methods to the existing scripts. The code in the controllers/studentsCourses.php
file is as follows:
public function get(){ $this->view->studentsCourses_data = $this->model->getStudentsCourses(); $this->view->render('studentsCourses/get'); }
The code in the models/studentsCourses_model.php
file is as follows:
public function getStudentsCourses(){ $stmt = $this->db->prepare("SELECT s.first_name, s.last_name, s.student_id, c.course_id, c.name as course_name FROM students_courses sc INNER JOIN students s ON sc.student_id=s...