-
Notifications
You must be signed in to change notification settings - Fork 0
/
storeInventoryResults.php
45 lines (40 loc) · 1.36 KB
/
storeInventoryResults.php
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
<?php
// ini_set('display_errors', 1);
include("includes/header.php");
require_once ("../../mysqli_Coffee_config.php"); // Connect to the database
$productID = $_GET['productID'];
$itemName = "%".$_GET['itemName']."%";
$query = "SELECT * FROM Item WHERE productID = ?
UNION
SELECT * FROM Item WHERE itemName LIKE ?";
$stmt = mysqli_prepare($dbc, $query);
mysqli_stmt_bind_param($stmt, 'ss', $productID, $itemName);
mysqli_stmt_execute($stmt);
$results = mysqli_stmt_get_result($stmt);
if (mysqli_num_rows($results) >= 1){
$searchResults = mysqli_fetch_assoc($results);
echo("<table class=\"queryResults\">");
echo ("<h2 class=\"tableHeader\">Product Details</h2>");
echo ("<tr>");
echo ("<th>SupplierID</th>");
echo ("<th>ProductID</th>");
echo ("<th>Item Name</th>");
echo ("<th>Item Price</th>");
echo ("<th>Item Weight</th>");
echo ("<th>Expiration Date</th>");
echo ("</tr>");
echo("<tr>");
foreach($searchResults as $product => $productDetails){
echo("<td>$productDetails</td>");
}
echo("</tr>");
}
else{
echo("<h2 class=\"noResult\">No product found</h2>");
}
mysqli_free_result($results);
?>
</table>
</main>
</body>
</html>