-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweeklyMenu.php
More file actions
executable file
·82 lines (63 loc) · 1.84 KB
/
weeklyMenu.php
File metadata and controls
executable file
·82 lines (63 loc) · 1.84 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
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
<?php
$servername = "localhost";
$username = "cyborg";
$password = "toor";
$dbname = "lab";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM menu";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$i=0;
$print = "<tr><th></th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th></tr>";
$print = $print."<tr><th>Breakfast</th>";
$food = "SELECT food FROM menu WHERE time='Breakfast'";
$foodresult=$conn->query($food);
if($foodresult->num_rows>0){
while($row=$foodresult->fetch_assoc()){
$print = $print."<th>".$row['food']."</th>";
}
$print=$print."</tr>";
}
$print=$print."<tr><th>Lunch</th>";
$food = "SELECT food FROM menu WHERE time='Lunch'";
$foodresult=$conn->query($food);
if($foodresult->num_rows>0){
while($row=$foodresult->fetch_assoc()){
$print=$print. "<th>".$row['food']."</th>";
}
$print=$print. "</tr>";
}
$print=$print. "<tr><th>Dinner</th>";
$food = "SELECT food FROM menu WHERE time='Dinner'";
$foodresult=$conn->query($food);
if($foodresult->num_rows>0){
while($row=$foodresult->fetch_assoc()){
$print=$print. "<th>".$row['food']."</th>";
}
$print=$print. "</tr>";
}
} else {
echo "0 results";
}
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>My Mess</title>
<link rel="stylesheet" type="text/css" href="styles/register.css">
</head>
<body>
<a class='logout' href='http://localhost:80/ZEUS/logout.php'>Logout</a>
<a class='home' href='http://localhost:80/ZEUS/admin.php'>Home</a>
<div id="tableBack"></div>
<table><?php echo $print;?>
</table>
</body>
</html>