exec($sql); } catch (PDOException $e) { // Ignore errors, like column already exists } } } 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->prepare("SELECT * FROM tasks WHERE user_id = ? ORDER BY created_at DESC"); $stmt->execute([$_SESSION['user_id']]); $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.