-
Notifications
You must be signed in to change notification settings - Fork 1
/
food_items.php
57 lines (48 loc) · 1.57 KB
/
food_items.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
46
47
48
49
50
51
52
53
54
55
56
57
<html>
<head>
<meta charset="UTF-8">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<title>Food Items</title>
</head>
<body>
<?php
require_once('Connection.php');
try {
$connection = new Connection();
$query = "SELECT * FROM `food_items`";
$result = $connection->connectToDb()->query($query);
echo "<table class='table'>
<thead>
<tr>
<th scope='col'>Name</th>
<th scope='col'>Description</th>
<th scope='col'>Price</th>
<th scope='col'>Available</th>
</tr>
</thead>
<tbody>";
if ($result->num_rows >= 1) {
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "<td>" . $row['is_available'] . "</td>";
echo "</tr>";
}
echo " </tbody>";
echo "</table>";
}
} catch (Exception $e) {
http_response_code(401);
echo('Message: ' . $e->getMessage());
$message = json_encode(array("message" => $e->getMessage(), "status" => false));
echo $message;
}
?>
</body>
</html>