-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderList.php
More file actions
41 lines (35 loc) · 996 Bytes
/
Copy pathOrderList.php
File metadata and controls
41 lines (35 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php // <--- do NOT put anything before this PHP tag
include_once('./functions.php');
include('./views/partials/head.php');
include('./views/partials/navbar.php');
$heading = "Orders";
$bannerMessage = "Orders made on our platform so far.";
// $marqueeDuration = 9;
include('./views/partials/banner.php');
?>
<?php
$dbh = connectToDatabase();
$sql = "
SELECT
o.OrderID,
o.TimeStamp,
SUM(op.Quantity) AS TotalItems,
SUM(op.Quantity * p.Price) AS TotalPrice,
c.CustomerID,
c.UserName,
c.FirstName,
c.LastName,
c.Address,
c.City
FROM Orders o
LEFT JOIN OrderProducts op ON op.OrderID = o.OrderID
LEFT JOIN Products p ON p.ProductID = op.ProductID
JOIN Customers c ON o.CustomerID = c.CustomerID
GROUP BY
o.OrderID, o.TimeStamp,
c.CustomerID, c.UserName, c.FirstName, c.LastName, c.Address, c.City
";
$statement = $dbh->prepare($sql);
$statement->execute();
$rows = $statement->fetchAll(PDO::FETCH_ASSOC);
include('./views/OrderList.view.php');