-
Notifications
You must be signed in to change notification settings - Fork 0
/
foodtest.php
110 lines (96 loc) · 2.38 KB
/
foodtest.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
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
<?php
session_start();
$db = mysqli_connect('localhost','root','','Student');
if(isset($_GET['action']) && $_GET['action']=="add")
{
$fname=$_GET['name'];
$fprice=$_GET['price'];
$id=$_SESSION["orderid"];
$query="INSERT INTO orders (orderid,name,price) VALUES ('$id','$fname','$fprice')";
mysqli_query($db,$query);
}
?>
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: separate;
border-spacing:1px;
width:100%;
}
td,th{
border: 1px solid #white;
text-align:center;
padding:18px;
}
td{
background:#fefefe;
opacity:0.8;
}
.button {
background-color: #ddd;
border: none;
color: black;
padding: 10px 20px;
text-align: center;
text-decoration: none;
/*display: inline-block;*/
margin: 4px 2px;
cursor: pointer;
border-radius: 16px;
}
.button1{
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 25%;
}
.button1:hover {
opacity: 0.8;
}
.button:hover {
background-color: #f1f1f1;
}
a{
text-decoration: none;
color: #000;
}
h2{
color: #fefefe;
}
</style>
</head>
<body background="images/brynii.png">
<h2 style="text-align: center" >FOOD MENU</h2>
<table>
<tr bgcolor=#4CAF50>
<th><i><strong>FOOD</strong></i></th>
<th><i><strong>PRICE</strong></i></th>
<th><i><strong>ADD TO ORDER</strong></i></th>
</tr>
<?php
$db = mysqli_connect('localhost','root','','Student');
$query = "SELECT foodname,price FROM food";
$result = mysqli_query($db,$query);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td> ". $row["foodname"]. "</td> ";
echo "<td> ". $row["price"]. "</td> ";
echo "<td><button class='button'><a href='foodtest.php?page=foodtest&action=add&name={$row['foodname']}&price={$row['price']}'>Add to cart</a></button></td>";
echo"</tr>";
}
echo"</table>";
echo"<button class='button1' style='float:right'><a href='cart.php'><b>NEXT<b></a>";
echo"<button class='button1'><a href='juice.php'><b>JUICE MENU</b></a>";
}
else {
echo "0 results";
}
?>