Part A: MySQL Query/Exec   Create StudentsDB database in MySQL server with the following table: Table: Students   uid int, Primary Key, Auto Increment studentID varchar(8), Unique name varchar(50) major varchar(50) passedCredits int CGPA float   Implement the following PHP scripts as required below:   php: the script should display student’s info (StudentID, name, major, credits passed and CGPA) in HTML table with appropriate title for each column. Student cells/rows should be highlighted as follows:   Condition Highlight Color Student At Risk: CGPA < 2.0 Red for CGPA Cell Expected to graduate: Passed Credits >=115 Yellow for Passed Credits Cell Outstanding Student: CGPA = 3.5 or above Green for the entire Student Row   php: This script should display all students’ names and major. Each student will be identified by a checkbox (define the checkbox name as a numeric array holding the uid). The user should be able to choose which student to be deleted by using its corresponding checkboxes. When the user clicks on the delete selected students button, your script should display (“Are you sure you want to delete N student’s records?” where N represents the number of selected students) and two buttons (Confirm and Cancel). Your script should delete the records permanently if the user decides to click on confirm button. If the user clicks on Cancel, the script should take the user to the first page where the user can re-select the students. Appropriate error message should be displayed in case the user didn’t select any checkbox.   (No JavaScript is allowed to solve this exercise; you may need to use json_encode/json_decode functions with hidden form element to solve this part)   php: Add login page so that only authorized users can view and delete students’ records. You will need to add new DB table called users and make sure all pages defined in Sections 1 and 2 are only accessible by authorized users.

A Guide to SQL
9th Edition
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Philip J. Pratt
Chapter2: Database Design Fundamentals
Section: Chapter Questions
Problem 11RQ
icon
Related questions
Question

 

 

Part A: MySQL Query/Exec

 

Create StudentsDB database in MySQL server with the following table:

Table: Students

 

uid

int, Primary Key, Auto Increment

studentID

varchar(8), Unique

name

varchar(50)

major

varchar(50)

passedCredits

int

CGPA

float

 

Implement the following PHP scripts as required below:

 

  1. php: the script should display student’s info (StudentID, name, major, credits passed and CGPA) in HTML table with appropriate title for each column. Student cells/rows should be highlighted as follows:

 

Condition

Highlight Color

Student At Risk: CGPA < 2.0

Red for CGPA Cell

Expected to graduate: Passed Credits >=115

Yellow for Passed Credits Cell

Outstanding Student: CGPA = 3.5 or above

Green for the entire Student Row

 

  1. php: This script should display all students’ names and major. Each student will be identified by a checkbox (define the checkbox name as a numeric array holding the uid). The user should be able to choose which student to be deleted by using its corresponding checkboxes. When the user clicks on the delete selected students button, your script should display (“Are you sure you want to delete N student’s records?” where N represents the number of selected students) and two buttons (Confirm and Cancel). Your script should delete the records permanently if the user decides to click on confirm button. If the user clicks on Cancel, the script should take the user to the first page where the user can re-select the students. Appropriate error message should be displayed in case the user didn’t select any checkbox.

 

(No JavaScript is allowed to solve this exercise; you may need to use json_encode/json_decode functions with hidden form element to solve this part)

 

  1. php: Add login page so that only authorized users can view and delete students’ records. You will need to add new DB table called users and make sure all pages defined in Sections 1 and 2 are only accessible by authorized users.

 

Part 2: Prepared Statements/Transaction

 

Define ordersDB database in MySQL server that contains the following 2 tables as follows:

Table 1: Orders

Table 2: OrderItems

 

orderID

int, Primary Key, Auto Increment

userID

int

total

double

orderDate

datetime

 

itemID

int, Primary Key, Auto Increment

orderID

int, Foreign Key

productName

varchar(50)

quantity

int

unitPrice

double

 

Design a simple login page with the necessary Users table in the DB. Implement the login page. When the user log-in successfully, his ID should be stored as follows:

$_SESSION[‘activeUserID’]=$UserID;

 

After the login page:

  1. The first webpage should ask for the number of products to be ordered
  2. The second webpage should display a form to enter all products information (product’s name, quantity, unit price) according to the number of products specified in the first webpage.
  3. The third webpage should process all products info from the products form and insert them into the orders and orderItems Your script should insert the userID, order total amount and order date and time into the orders table and then insert each product details in the orderItems table. Your script should make sure All details are inserted successfully or none of them (Use Transaction). In addition, you should insert all products items into the OrderItems table using PDO PREPARED STATEMENTS.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Dataset
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr