prepare("DELETE FROM travel_plans WHERE id = ?"); $stmt->execute([$planIdToDelete]); } catch (PDOException $e) { error_log("Database error: " . $e->getMessage()); } } // Handle new travel plan creation if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['destination'])) { $destination = trim($_POST['destination']); $startDate = trim($_POST['start_date']); $endDate = trim($_POST['end_date']); $notes = trim($_POST['notes']); if (!empty($destination)) { try { $pdo = db(); $stmt = $pdo->prepare("INSERT INTO travel_plans (destination, start_date, end_date, notes) VALUES (?, ?, ?, ?)"); $stmt->execute([$destination, $startDate, $endDate, $notes]); } catch (PDOException $e) { error_log("Database error: " . $e->getMessage()); } } } // Fetch all travel plans $plans = []; try { $pdo = db(); $stmt = $pdo->query("SELECT id, destination, start_date, end_date, notes FROM travel_plans ORDER BY start_date DESC, created_at DESC"); $plans = $stmt->fetchAll(); } catch (PDOException $e) { error_log("Database error: " . $e->getMessage()); } ?>
Organize your upcoming trips.
No travel plans yet.
to