exec($sql); } } catch (PDOException $e) { // In a real app, you'd log this error. // For now, we'll just output a generic error. die("Database migration failed: " . $e->getMessage()); } } // Run migrations run_migrations(); // Fetch tasks $tasks = []; try { $pdo = db(); $stmt = $pdo->query("SELECT * FROM tasks ORDER BY created_at DESC"); $tasks = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { echo '
Database error: Could not fetch tasks.
'; } $tasks_by_status = [ 'To Do' => [], 'In Progress' => [], 'Done' => [] ]; foreach ($tasks as $task) { if (isset($tasks_by_status[$task['status']])) { $tasks_by_status[$task['status']][] = $task; } } ?>
$tasks_in_status): ?>

No tasks yet.