diff --git a/index.php b/index.php new file mode 100644 index 0000000..3d33f72 --- /dev/null +++ b/index.php @@ -0,0 +1,107 @@ + $new_todo, + 'priority' => $priority, + 'done' => false + ]; + } +} + +// Mark Task done or undone +if (isset($_GET['toggle'])) { + $index = intval($_GET['toggle']); + if (isset($_SESSION['todo_list'][$index])) { + $_SESSION['todo_list'][$index]['done'] = !$_SESSION['todo_list'][$index]['done']; + } +} + +// Delete Task +if (isset($_GET['delete'])) { + $index = intval($_GET['delete']); + if (isset($_SESSION['todo_list'][$index])) { + array_splice($_SESSION['todo_list'], $index, 1); + } +} + +// Sort by priority (high -> medium -> low) +usort($_SESSION['todo_list'], function($a, $b) { + $priorityOrder = [ + 'high' => 3, + 'medium' => 2, + 'low' => 1 + ]; + return $priorityOrder[$b['priority']] <=> $priorityOrder[$a['priority']]; +}); +?> + + + + + + + To-Do List + + + + +
+

To-Do List

+
+
+
+
+ + + +
+
+ +
+
+
+ + +