Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: Order

image text in transcribed
image text in transcribed
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: Order Items order ID int, Primary Key, Auto itemID int, Primary Key, Auto Increment Increment userID int order ID int, Foreign Key total double productName varchar(50) order Date datetime quantity int unit Price double Use the following Connection.php by including it in your scripts which connect you to MySQL server and the database. setAttribute(PDO::ATTR ERRMODE, PDO::ERRMODE EXCEPTION); 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"]=SUser ID; for each Product in the shopping cart: $_SESSION[SUserID][SProductName] = array(SQuantity, $UnitPrice); 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 order Items 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago