-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderDetails.php
More file actions
80 lines (66 loc) · 2.67 KB
/
OrderDetails.php
File metadata and controls
80 lines (66 loc) · 2.67 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!-- Author: Kevin Kemmerer -->
<!-- CS485 Customer Orders Database Lookup -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Customer Orders</title>
<meta charset="UTF-8">
<meta name="author" content="Kevin Kemmerer">
</head>
<body>
<div id="navbar">
<p id="menuul">
<li><a href="Order_Status.html">** Click here to Return **</a></li>
</p>
</div>
<div class="main">
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
// get comments/email
$OrderNumber = $_POST['OrderNumber'];
$Customer_Name = $_SESSION['CustomerName'];
echo "<h2> Order Number: ". $OrderNumber ."</h2>";
echo "<br>";
echo "<h3> Customer Name: ". $Customer_Name ."</h2>";
$servername = "localhost:3306";
// Change username and password here if needed
$username = "test";
$password = "test";
$dbname = "classicmodels";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT p.productName AS 'Product Name', od.quantityOrdered AS 'Quantity', p.buyPrice AS 'Bought At', od.priceEach AS 'Price'
FROM orderdetails AS od
JOIN products AS p ON od.productCode = p.productCode
JOIN orders AS o ON od.orderNumber = o.orderNumber
WHERE o.orderNumber LIKE '%$OrderNumber%'";
$result = $conn->query($sql);
echo "<table border='1'>
<tr>
<th>Product Name</th>
<th>Quantity</th>
<th>Bought At</th>
<th>Price</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Product Name'] . "</td>";
echo "<td>" . $row['Quantity'] . "</td>";
echo "<td>" . $row['Bought At'] . "</td>";
echo "<td>" . $row['Price'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo date('Y-m-d');
mysqli_close($conn);
?>
</div>
</body>
</html>