setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);} ?> Assume a user has logged in successfully and added many products of different quantities in his shopping basket. All this information is saved in Session Variables as follows: $_SESSION['activeUser'] holds the username $_SESSION['CART'] holds an associative array whose key is the product id and its value is the quantity selected.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
ts
Question 4 MYSQL/PHP
Assume you have an ORDERS database stored in MYSQL server that contains the
following tables with unknown number of rows:
Table: customer_orders
Table: order_Items
Name
Type
Name
Туре
1 ld
Int(11)
Id
int(11)
2 username varchar(100)
orderld
int(11)
3 datetime datetime
productid int(11)
4 status
varcha 100)
qty
int(11)
Note: ordered is a foreign key to an id in
customer_orders
Sample Data
Table: customer_orders
Table: order_items
id username
datetime
status
id orderld productid qty
1 falqaed
2021-11-04 00:00:00 Order Placed
11
2 1
2 noor
2021-11-04 00:00:00 Order Placed
3 1
3
4
2
5 2
6 2
Use the following connection.php by including it in your scripts, which connects you
to MYSQL server and the database.
...
<?php
$db=new PDO('mysql:host%=localhost;dbname=ORDERS;charset=Dutf8', 'root', 'abc12');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);}
Transcribed Image Text:ts Question 4 MYSQL/PHP Assume you have an ORDERS database stored in MYSQL server that contains the following tables with unknown number of rows: Table: customer_orders Table: order_Items Name Type Name Туре 1 ld Int(11) Id int(11) 2 username varchar(100) orderld int(11) 3 datetime datetime productid int(11) 4 status varcha 100) qty int(11) Note: ordered is a foreign key to an id in customer_orders Sample Data Table: customer_orders Table: order_items id username datetime status id orderld productid qty 1 falqaed 2021-11-04 00:00:00 Order Placed 11 2 1 2 noor 2021-11-04 00:00:00 Order Placed 3 1 3 4 2 5 2 6 2 Use the following connection.php by including it in your scripts, which connects you to MYSQL server and the database. ... <?php $db=new PDO('mysql:host%=localhost;dbname=ORDERS;charset=Dutf8', 'root', 'abc12'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);}
4 1
1.
5 2
82
Use the following connection.php by including it in your scripts, which connects you
to MYSQL server and the database.
<?php
$db=new PDO('mysql:host=localhost;dbname-ORDERS;charset=utf8', 'root', 'abc12');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);}
?>
Assume a user has logged in successfully and added many products of different
quantities in his shopping basket. All this information is saved in Session Variables as
follows:
• $_SESSION['activeUser'] holds the username
$_SESSION['CART'] holds an associative array whose key is the product id and its
value is the quantity selected.
Q4-A: Write the required PHP statements to insert the customer order from the
shopping basket into the two database tables. Your code must ensure that the order is
completely inserted successfully or not. In addition, you must use prepared statement
to insert the order items. Once inserted all, your code should display the number of
items inserted successfully in green color.
Use the editor to format your answer
Transcribed Image Text:4 1 1. 5 2 82 Use the following connection.php by including it in your scripts, which connects you to MYSQL server and the database. <?php $db=new PDO('mysql:host=localhost;dbname-ORDERS;charset=utf8', 'root', 'abc12'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);} ?> Assume a user has logged in successfully and added many products of different quantities in his shopping basket. All this information is saved in Session Variables as follows: • $_SESSION['activeUser'] holds the username $_SESSION['CART'] holds an associative array whose key is the product id and its value is the quantity selected. Q4-A: Write the required PHP statements to insert the customer order from the shopping basket into the two database tables. Your code must ensure that the order is completely inserted successfully or not. In addition, you must use prepared statement to insert the order items. Once inserted all, your code should display the number of items inserted successfully in green color. Use the editor to format your answer
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY