Please fill in all required fields.';
} else {
try {
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO food_listings (user_id, title, description, quantity, food_type, prepared_time, pickup_deadline) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$user_id, $title, $description, $quantity, $food_type, $prepared_time, $pickup_deadline]);
$message = '
Food listing created successfully!
';
} catch (PDOException $e) {
$message = 'Error: ' . $e->getMessage() . '
';
}
}
}
// Fetch existing listings for this restaurant
$listings = [];
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM food_listings WHERE user_id = ? ORDER BY created_at DESC");
$stmt->execute([$_SESSION['user_id']]);
$listings = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// Handle error
}
?>
Restaurant Dashboard
Logout
Welcome, !
Your Food Listings
You haven't posted any food listings yet.