Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By : Sai S Sriparasa
Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By: Sai S Sriparasa

Overview of this book

Table of Contents (17 chapters)
Building a Web Application with PHP and MariaDB: A Reference Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Viewing all registrations


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...