PHP CODE Using the MicroUniversity.db3 database and the MVC structure with beaut
ID: 3662884 • Letter: P
Question
PHP CODE
Using the MicroUniversity.db3 database and the MVC structure with beautiful URLs discussed in the recitation, create a set of web pages that will allow for the listing and view of employees. In particular the “employee/list” URL should list all employees using their name, and the “employee/view/X” URL should show all the details of employee with EMP_NUM equal to X. On the employee list page, link the employee’s name to the view URL to see the details of the employee. Create an “index.php” that merely redirects the browser to the employee list.
Explanation / Answer
You have not provided access to database mentioned in the problem statement neither you have listed database schema. Hence, it is not possible to know the exact database structure. However, given below are relevant scripts that will help in completing the work. You will be required to replace the marked sections with relevant information.
1. Redirecting to a new location:
-----------------------------------------
<?php
//provide url of page where to redirect. you can place this code in index.php.
header("Location: <redirection-url>");
?>
--------------------------------------
2. Connecting and querying database: Default database for PHP is MYSQL. But, your database(.db3) is a SQLite database. Following scripts shows how to connect to a SQLite database.
-------------------------------------------
------------------------------------------------
Note: You can use the same syntax to create and execute your queries. At a minimum, you will require three files: a) index.php: For redirecting to employeelist.php
b) employeelist.php: Connects to database, executes query to fetch employees and displays their list by name.
c) employeedetails.php: Executes the query and displays the details of a given employee.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.