1 00:00:00,330 --> 00:00:02,415 Now that we've completed adding projects, 2 00:00:02,415 --> 00:00:07,470 we're going to perform those same processes for adding tasks. 3 00:00:07,470 --> 00:00:12,150 Reading the task table and populating our task list, accepting and 4 00:00:12,150 --> 00:00:17,090 filtering user data, and finally, writing that data to the database. 5 00:00:17,090 --> 00:00:17,940 Once again, 6 00:00:17,940 --> 00:00:21,550 we'll start with reading the data we want to show on the task list page. 7 00:00:23,160 --> 00:00:28,307 Back in functions.php, let's duplicate the get_project_list. 8 00:00:31,368 --> 00:00:34,050 And we'll name it get_task_list. 9 00:00:35,990 --> 00:00:38,760 The SQL statement is going to be a little more complicated, so 10 00:00:38,760 --> 00:00:40,530 let's move it out of the query method. 11 00:00:50,461 --> 00:00:55,075 For this select, we want to pull all the task 12 00:00:55,075 --> 00:01:00,430 Information so we use SELECT * FROM tasks. 13 00:01:00,430 --> 00:01:04,050 But we also want to pull the project title, so 14 00:01:04,050 --> 00:01:06,360 we're going to join these tables. 15 00:01:06,360 --> 00:01:10,641 Let's add this on a second line, 16 00:01:10,641 --> 00:01:15,240 JOIN projects ON. 17 00:01:15,240 --> 00:01:19,690 Since the task and project tables both have project IDs, 18 00:01:19,690 --> 00:01:22,348 we need to specify which table we're talking about, 19 00:01:22,348 --> 00:01:27,714 tasks.project_id = 20 00:01:27,714 --> 00:01:33,340 projects.project_id. 21 00:01:33,340 --> 00:01:34,970 We also need to edit our SELECT. 22 00:01:36,150 --> 00:01:43,060 Instead of just saying select all, we want to add tasks.all. 23 00:01:43,060 --> 00:01:47,910 We also want to pull the project title, but since the tasks table and 24 00:01:47,910 --> 00:01:51,430 the projects table both have fields named title, 25 00:01:51,430 --> 00:01:55,110 we need to specify projects.title and 26 00:01:55,110 --> 00:02:01,350 then the keyword as followed by an alias or new name. 27 00:02:01,350 --> 00:02:03,150 We want to use project. 28 00:02:05,840 --> 00:02:09,030 Now, we can use this function for our task list. 29 00:02:09,030 --> 00:02:12,570 Go to the project_list and copy this foreach loop. 30 00:02:14,920 --> 00:02:16,570 Then open tasks_list. 31 00:02:18,510 --> 00:02:21,954 In our unordered list, we're going to paste and 32 00:02:21,954 --> 00:02:25,575 change get_project_list to get_task_list. 33 00:02:25,575 --> 00:02:26,880 Great job. 34 00:02:26,880 --> 00:02:28,790 Let's take a look at this page in the browser. 35 00:02:31,318 --> 00:02:34,920 Now, our Task List page shows a list of all our tasks.