-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.php
84 lines (76 loc) · 2.84 KB
/
menu.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
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
<?php
include('dbconnection.php');
session_start();
$query = "SELECT * FROM food_items ORDER BY id ASC";
$run_query = mysqli_query($connection, $query);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Menu</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<style>
.top_header { width: 100%; }
h2 { width: 60%; float: left; }
#cart { float: right; margin-left: 5px; margin-right: 5px; display: block;}
input[type=submit]
{
background-color: #4CAF50; color: white; padding: 6px 10px; border: none; border-radius: 4px; cursor: pointer; float: inherit;
}
input[type=submit]:hover, input[type=file]:hover
{ background-color: #45a049; }
table { width: 100%; padding: 10px; }
</style>
</head>
<body>
<div class="container">
<div class="top_header">
<h2>FOOD ITEMS</h2>
<a href="cart.php"><input id="cart" value="Cart" type="submit" class="btn btn-successs"></a>
<a href="index.php"><input id="cart" value="Home" type="submit" class="btn btn-successs"></a>
</div><br><br><br>
<table class="table table-bordered table table-hover">
<thead>
<tr>
<th>Image</th>
<th>Name</th>
<th>Price</th>
<th>Add to Cart</th>
</tr>
</thead>
<tbody>
<?php
while( $result = mysqli_fetch_assoc($run_query) )
{
if($result) {
?>
<tr>
<td><img src='<?php echo $result["Image"]; ?>' width="150" height="150" ></td>
<td><?php echo "<b>".$result['Name']."</b>"."<br>".$result['description'] ; ?></td>
<td><?php echo "$".$result['Price']; ?></td>
<td>
<?php if(!isset($_SESSION['email'])) { ?>
<a href="register.php"><input type="submit" name="add" style="margin-top: 5px;" value="Add to Cart"></a>
<?php } else { ?>
<form method="POST" action="insrt_cart.php">
<input type="number" name="quantity" class="form-control" value="1">
<input type="hidden" name="hidden_name" value="<?php echo $result['Name']; ?>">
<input type="submit" name="add" style="margin-top: 5px;" value="Add to Cart">
</form>
<?php } ?>
</td>
</tr>
<?php
} }
mysqli_close($connection);
?>
</tbody>
</table>
</div>
</body>
</html>