Order from Majuro's best
-
-
-
All Cuisines
- query("SELECT DISTINCT cuisine FROM restaurants ORDER BY cuisine");
- $cuisines = $cuisine_stmt->fetchAll(PDO::FETCH_COLUMN);
- $search_param = isset($_GET['search']) ? '&search=' . urlencode($_GET['search']) : '';
- foreach ($cuisines as $cuisine):
- ?>
-
= htmlspecialchars($cuisine) ?>
-
+
+
+
+
+
All Cuisines
+ query("SELECT DISTINCT cuisine FROM restaurants ORDER BY cuisine");
+ $cuisines = $cuisine_stmt->fetchAll(PDO::FETCH_COLUMN);
+ $search_param = isset($_GET['search']) ? '&search=' . urlencode($_GET['search']) : '';
+ foreach ($cuisines as $cuisine):
+ ?>
+
= htmlspecialchars($cuisine) ?>
+
+
+
diff --git a/migrations/20251015_add_role_to_users.sql b/migrations/20251015_add_role_to_users.sql
new file mode 100644
index 00000000..6ddf2a91
--- /dev/null
+++ b/migrations/20251015_add_role_to_users.sql
@@ -0,0 +1 @@
+ALTER TABLE users ADD COLUMN role VARCHAR(255) NOT NULL DEFAULT 'customer';
\ No newline at end of file
diff --git a/migrations/20251015_add_user_id_to_restaurants.sql b/migrations/20251015_add_user_id_to_restaurants.sql
new file mode 100644
index 00000000..1f8a0e41
--- /dev/null
+++ b/migrations/20251015_add_user_id_to_restaurants.sql
@@ -0,0 +1,2 @@
+ALTER TABLE restaurants ADD COLUMN user_id INT NULL;
+ALTER TABLE restaurants ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL ON UPDATE CASCADE;
\ No newline at end of file
diff --git a/order_history.php b/order_history.php
new file mode 100644
index 00000000..a53ee001
--- /dev/null
+++ b/order_history.php
@@ -0,0 +1,56 @@
+prepare("SELECT * FROM orders WHERE user_id = ? ORDER BY order_date DESC");
+$stmt->execute([$user_id]);
+$orders = $stmt->fetchAll();
+
+?>
+
+
+
My Order History
+
+
+
+
You have not placed any orders yet.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/order_status.php b/order_status.php
new file mode 100644
index 00000000..33642766
--- /dev/null
+++ b/order_status.php
@@ -0,0 +1,123 @@
+
No order specified.
";
+ include 'footer.php';
+ exit();
+}
+
+$order_id = $_GET['order_id'];
+$user_id = $_SESSION['user_id'];
+
+// Fetch order details to ensure the user owns this order
+$p_order = $db->prepare("SELECT o.*, r.name as restaurant_name FROM orders o JOIN restaurants r ON o.restaurant_id = r.id WHERE o.id = ? AND o.user_id = ?");
+$p_order->execute([$order_id, $user_id]);
+$order = $p_order->fetch(PDO::FETCH_ASSOC);
+
+if (!$order) {
+ echo "You are not associated with any restaurant.
";
+ include 'footer.php';
+ exit;
+}
+$restaurant_id = $restaurant['id'];
+
+// Handle form submission
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $name = $_POST['name'] ?? '';
+ $cuisine = $_POST['cuisine'] ?? '';
+ $address = $_POST['address'] ?? '';
+ $phone_number = $_POST['phone_number'] ?? '';
+ $image_url = $_POST['image_url'] ?? '';
+
+ if ($name && $cuisine && $address) {
+ $update_stmt = $pdo->prepare("UPDATE restaurants SET name = ?, cuisine = ?, address = ?, phone_number = ?, image_url = ? WHERE id = ? AND user_id = ?");
+ $update_stmt->execute([$name, $cuisine, $address, $phone_number, $image_url, $restaurant_id, $owner_id]);
+
+ // Redirect to the dashboard with a success message
+ $_SESSION['success_message'] = "Your restaurant details have been updated successfully!";
+ header('Location: index.php');
+ exit;
+ } else {
+ $error = "Name, Cuisine, and Address are required fields.";
+ }
+}
+
+// Fetch current restaurant details
+$stmt = $pdo->prepare("SELECT * FROM restaurants WHERE id = ?");
+$stmt->execute([$restaurant_id]);
+$restaurant_details = $stmt->fetch();
+
+?>
+
+