-- Create table to store ToDo items CREATE TABLE IF NOT EXISTS todos ( id INTEGER PRIMARY KEY, task TEXT NOT NULL, completed BOOLEAN DEFAULT FALSE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- Display form for adding or editing a ToDo item SELECT 'form' AS component, 'multipart/form-data' AS enctype; SELECT CASE WHEN $edit IS NOT NULL THEN (SELECT task FROM todos WHERE id = $edit) ELSE '' END AS value, 'task' AS name, 'text' AS type, 'Enter or edit your task' AS placeholder; -- Insert new task or update existing one INSERT INTO todos (task) SELECT :task WHERE :task IS NOT NULL AND $edit IS NULL; UPDATE todos SET task = :task WHERE id = $edit AND :task IS NOT NULL; -- Mark task as complete UPDATE todos SET completed = TRUE WHERE id = $complete; -- Delete a task DELETE FROM todos WHERE id = $delete; -- Display existing ToDo items in a table, along with links to perform database operations SELECT 'table' AS component, 'ToDo List' AS title, 'Completed' AS markdown, 'Complete_Action' AS markdown, 'Edit_Action' AS markdown, 'Remove_Action' AS markdown, TRUE AS sort, TRUE AS search; SELECT id AS ID_Number, task AS Task, CASE WHEN completed THEN 'Yes' ELSE 'No' END AS Completed, '[Complete](todo.sql?complete=' || id || ')' AS Complete_Action, '[Edit](todo.sql?edit=' || id || ')' AS Edit_Action, '[Remove](todo.sql?delete=' || id || ')' AS Remove_Action FROM todos;