Sdb-new PDO('mysql:host-localhost;dbname-ordersDB;charset-utf8', 'root', 'abc123); Sdb->setAttribute(PDO::ATTR_ERRMODE, PDO:ERRMODE EXCEPTION); Assume the user has added several products in his shopping cart and all his selection is stored in PHP Session variable using the following data structure: When the user log-in successfully, his ID is stored as follows: $_SESSION['activeUserID'J-SUserID; for each Product in the shopping cart: $ SESSION[SUserlID][SProductName] = array($Quantity, SUnitPrice); Implement placeOrder.php as follows: the script should process all products info from the User shopping cart SESSION and insert them into the orders and orderItems tables. 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. In addition, you should insert all products items into the OrderItems table using PDO PREPARED STATEMENTS.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Sab-new PDO(mysql:host-localbost;dbname-ordersDB;charset-utf8', 'root', abc123);
Sdb->setAttribute(PDO::ATTR_ERRMODE, PDO:ERRMODE EXCEPTION);
Assume the user has added several products in his shopping cart and all his selection
is stored in PHP Session variable using the following data structure:
When the user log-in successfully, his ID is stored as follows:
S_SESSION['activeUserID']=SUserID;
for each Product in the shopping cart:
$ SESSION[SUserID][SProductName] = array($Quantity, SUnitPrice);
Implement placeOrder.php as follows: the script should process all products info
from the User shopping cart SESSION and insert them into the orders and orderItems
tables. 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. In
addition, you should insert all products items into the OrderItems table using PDO
PREPARED STATEMENTS.
Transcribed Image Text:Sab-new PDO(mysql:host-localbost;dbname-ordersDB;charset-utf8', 'root', abc123); Sdb->setAttribute(PDO::ATTR_ERRMODE, PDO:ERRMODE EXCEPTION); Assume the user has added several products in his shopping cart and all his selection is stored in PHP Session variable using the following data structure: When the user log-in successfully, his ID is stored as follows: S_SESSION['activeUserID']=SUserID; for each Product in the shopping cart: $ SESSION[SUserID][SProductName] = array($Quantity, SUnitPrice); Implement placeOrder.php as follows: the script should process all products info from the User shopping cart SESSION and insert them into the orders and orderItems tables. 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. In addition, you should insert all products items into the OrderItems table using PDO PREPARED STATEMENTS.
PHP/MYSQL Question
Assume you have ordersDB database stored in MYSQL server that contains the
following 2 tables as follows:
...
Table 1: Orders
Table 2: OrderlItems
int, Primary Key, Auto
Increment
orderID
itemID
int, Primary Key, Auto
Increment
userID
int
orderID
int, Foreign Key
productName varchar(50)
int
total
double
orderDate
datetime
quantity
unitPrice
double
Use the following Connection.php by including it in your scripts which connect you
to MYSQL server and the database.
<?php
Sdb-new PDO('mysql:host-localhost;dbname-ordersDB;charset-utf8', 'root', 'abc123');
Sdb->setAttribute(PDO::ATTR ERRMODE, PD0::ERRMODE EXCEPTION);
Transcribed Image Text:PHP/MYSQL Question Assume you have ordersDB database stored in MYSQL server that contains the following 2 tables as follows: ... Table 1: Orders Table 2: OrderlItems int, Primary Key, Auto Increment orderID itemID int, Primary Key, Auto Increment userID int orderID int, Foreign Key productName varchar(50) int total double orderDate datetime quantity unitPrice double Use the following Connection.php by including it in your scripts which connect you to MYSQL server and the database. <?php Sdb-new PDO('mysql:host-localhost;dbname-ordersDB;charset-utf8', 'root', 'abc123'); Sdb->setAttribute(PDO::ATTR ERRMODE, PD0::ERRMODE EXCEPTION);
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Linux
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education