🔧 Step 3: Create an SQL table

Now that we have built the layouts and implemented those into our PHP engine as well, we need to store the data of our to-do list somewhere.
How would we structure our database?

Let’s keep it plain and simple and keep all the to-do tasks inside one table.
This table would have mutliple columns: id, title, description, status, date_created, due_date

This table would already help us differentiating the tasks by whether they are done or not, and we can see the title and description of each.

Create a table called “todo”

Add the following fields:
id – set PRIMARY and A_I (auto increment), and type as INT
title – varchar 255
description – text
status – int (so it can be 1 or 0), set default > As defined: > 0, so when it is created, it will automatically be “Not done”
date_created – date, with default value CURRENT_TIMESTAMP
due_date – date

Populate your table

Add a few entries to your table, so we could show them on the website!
Just click on the Insert tab in phpMyAdmin and start filling the table.

In the next lesson, we’ll be showing the results on our website, after which, we build a functionality to insert new to-do tasks from the database as well.

Scroll to Top