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.
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...
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);}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff4c7f0b9-7c99-4bd1-b467-440454deb853%2F59aa482e-cfd5-43c4-aa02-8ffba076487a%2Fhloctgp_processed.png&w=3840&q=75)
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff4c7f0b9-7c99-4bd1-b467-440454deb853%2F59aa482e-cfd5-43c4-aa02-8ffba076487a%2Fsy9kbca_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
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](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY