-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerOrders.php
More file actions
112 lines (92 loc) · 3.86 KB
/
CustomerOrders.php
File metadata and controls
112 lines (92 loc) · 3.86 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!-- 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
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
$file_name = "Users.txt";
$new_name = true;
// Did you actually enter a Customer Name?
if (isset($_POST['CustomerName']))
{
$CustomerName = $_POST['CustomerName'];
}
// get comments/email
$_SESSION['CustomerName'] = $CustomerName;
// $CustomerName = $_POST['CustomerName'];
echo "<h2> Customer Name: ". $CustomerName ."</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);
}
if ($CustomerName == null || !$CustomerName)
{
echo 'Please enter a Customer Name';
}
else
{
$sql = "SELECT o.orderNumber AS 'Order Number', CONCAT(c.contactFirstName,' ',c.contactLastName) AS 'Customer Contact', c.customerName AS 'Customer Name', o.status AS Status, o.orderDate AS 'Order Date', o.shippedDate AS 'Shipped Date'
FROM orders AS o
JOIN customers AS c ON o.customerNumber = c.customerNumber
WHERE c.customerName LIKE '%$CustomerName%';";
$result = $conn->query($sql);
echo "<table border='1'>
<tr>
<th>Order Number</th>
<th>Customer Contact</th>
<th>Customer Name</th>
<th>Status</th>
<th>Order Date</th>
<th>Shipped Date</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Order Number'] . "</td>";
echo "<td>" . $row['Customer Contact'] . "</td>";
echo "<td>" . $row['Customer Name'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
echo "<td>" . $row['Order Date'] . "</td>";
echo "<td>" . $row['Shipped Date'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
}
session_commit();
?>
</div>
<!-- Simple headers -->
<br>
<h2>Enter an order number for additonal information</h2>
<form action="OrderDetails.php" method="POST">
<p>Order Number:
<textarea type="text" name="OrderNumber" cols="20" rows="1"></textarea>
</p>
<div class="right">
<input type="submit" value="Submit">
</div>
</form>
</body>
</html>