-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·128 lines (110 loc) · 4.58 KB
/
index.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<title>Home</title>
<link rel="stylesheet" href="public/assets/css/main.css">
</head>
<body>
<!-- Header Section -->
<?php include 'src/components/header.php'; ?>
<!-- Hero Section -->
<section class="hero">
<div class="hero-button">
<div class="dropdown">
<button class="menu-button">
<i class="fas fa-bars"></i>
</button>
<div class="dropdown-content">
<a href="src/View/aboutus.php">About Us</a>
<a href="mailto:[email protected]">Contact us</a>
</div>
</div>
<h2>Delicious Meals Delivered To You</h2>
</div>
<div class="hero-content">
<p class="paragraph">Order your favorite meals with ease and get them delivered hot and fresh!</p>
<a href="src/View/menu.php" class="explore-button">Explore Menu</a>
</div>
</section>
<!-- Featured Dishes Section -->
<section>
<h2>Featured Dishes</h2>
<div class="dishes-container">
<?php
include 'config/db_connection.php';
// Query to fetch featured dishes
$sql = "SELECT imagePath, description, imageName FROM images LIMIT 4";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<div class="dish" onclick="openModal(\'' . htmlspecialchars($row['imageName']) . '\', \'' . htmlspecialchars($row['description']) . '\', \'' . $row['imagePath'] . '\')">';
echo '<img class="image" src="' . $row['imagePath'] . '" alt="Dish">';
echo '<h3>' . htmlspecialchars($row['imageName']) . '</h3>';
echo '</div>';
}
} else {
echo '<p>No featured dishes found.</p>';
}
$conn->close();
?>
</div>
</section>
<!-- Recently Searched Section -->
<section>
<h2>Recently Searched</h2>
<div class="dishes-container">
<?php
include 'config/db_connection.php';
// Query to fetch recently searched dishes
$sql = "SELECT imagePath, description, imageName FROM images ORDER BY id DESC LIMIT 4";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<div class="dish" onclick="openModal(\'' . htmlspecialchars($row['imageName']) . '\', \'' . htmlspecialchars($row['description']) . '\', \'' . $row['imagePath'] . '\')">';
echo '<img class="image" src="' . $row['imagePath'] . '" alt="Dish">';
echo '<h3>' . htmlspecialchars($row['imageName']) . '</h3>';
echo '</div>';
}
} else {
echo '<p>No recently searched dishes found.</p>';
}
$conn->close();
?>
</div>
</section>
<!-- Modal Structure -->
<div id="myModal" class="modal">
<div class="modal-content">
<img id="modalImage" src="" alt="Dish">
<div class="modal-details">
<span class="close" onclick="closeModal()">×</span>
<h2 id="modalTitle"></h2>
<p id="modalDescription"></p>
<a href="src/View/menu.php" class="go-to-menu-btn">Go to Menu</a>
</div>
</div>
</div>
<script>
function openModal(title, description, imagePath) {
document.getElementById('modalTitle').innerText = title;
document.getElementById('modalDescription').innerText = description;
document.getElementById('modalImage').src = imagePath;
document.getElementById('myModal').style.display = "block";
}
function closeModal() {
document.getElementById('myModal').style.display = "none";
}
// Close the modal when clicking outside of it
window.onclick = function(event) {
const modal = document.getElementById('myModal');
if (event.target == modal) {
closeModal();
}
}
</script>
<?php include 'src/components/footer.php'; ?>
</body>
</html>