-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInventory.php
More file actions
49 lines (42 loc) · 1.28 KB
/
Copy pathInventory.php
File metadata and controls
49 lines (42 loc) · 1.28 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
<!DOCTYPE html>
<html>
<head>
<title>Inventory</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<?php
require_once 'database.php';
$sql = "SELECT CENTER.CenterName, Inventory.BloodType, Inventory.DonationType, Inventory.DonationID
FROM Inventory
JOIN CENTER ON Inventory.CenterID = CENTER.CenterID";
try {
$stmt = $conn->prepare($sql);
} catch (PDOException $e) {
echo "Error preparing statement: " . $e->getMessage();
exit;
}
try {
$stmt->execute();
} catch (PDOException $e) {
echo "Error retrieving inventory: " . $e->getMessage();
exit;
}
if ($stmt->rowCount() > 0) {
echo "<h2>Current Inventory</h2>";
echo "<table>";
echo "<tr><th>Donation ID</th><th>Blood Type</th><th>Center Name</th><th>Donation Type</th></tr>";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>" . htmlspecialchars($row['DonationID']). "</td>";
echo "<td>" . htmlspecialchars($row['BloodType']) . "</td>";
echo "<td>" . htmlspecialchars($row['CenterName']) . "</td>";
echo "<td>" . htmlspecialchars($row['DonationType']) . "</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "Inventory is empty.";
}
$stmt = null; // Close the statement
?>