1 00:00:00,510 --> 00:00:02,630 The report page is looking good but 2 00:00:02,630 --> 00:00:06,270 it's hard to know which report is actually being run. 3 00:00:06,270 --> 00:00:08,770 Let's change our header text to include more details. 4 00:00:10,220 --> 00:00:13,270 Back in reports.php, find the h1 tag. 5 00:00:14,970 --> 00:00:22,409 Instead of reports, let's use Report on and then, we'll check the filter. 6 00:00:28,662 --> 00:00:33,582 If not is_array $filter then, 7 00:00:33,582 --> 00:00:39,564 we can simply echo All Tasks by Project. 8 00:00:46,498 --> 00:00:51,823 Else, if the filter is an array, we start by displaying the first element, 9 00:00:51,823 --> 00:00:55,250 which is the item we'll be using for our filter. 10 00:00:56,910 --> 00:01:02,740 We'll use the function ucwords to upper case the first letter for title case. 11 00:01:04,690 --> 00:01:05,930 Filter 0. 12 00:01:07,160 --> 00:01:11,530 Then, before we add the value, let's add a colon for separation. 13 00:01:13,500 --> 00:01:16,623 Now we can add the switch statement like we did in the function. 14 00:01:26,294 --> 00:01:33,707 If the first element in the filter array equals project, we need to 15 00:01:33,707 --> 00:01:39,370 use the second element of the filter array to pull project details from the database. 16 00:01:39,370 --> 00:01:42,220 We'll create a new function named get_project. 17 00:01:42,220 --> 00:01:44,293 For now, let's just pretend it's already there. 18 00:01:48,504 --> 00:01:54,766 We pass filter 1 and 19 00:01:54,766 --> 00:02:03,170 then, we can echo project title and break. 20 00:02:03,170 --> 00:02:08,050 Let's finish off the switch statement before we add the get_project function. 21 00:02:08,050 --> 00:02:11,515 If the first element of the filter array equals category, 22 00:02:15,590 --> 00:02:18,400 we can simply display the second element of the filter array. 23 00:02:25,713 --> 00:02:30,531 And, if the first element of the filter 24 00:02:30,531 --> 00:02:35,649 array equals date then, we echo filter 1 25 00:02:39,664 --> 00:02:42,332 to filter 2. 26 00:02:46,764 --> 00:02:49,914 Now we can go over to functions.php. 27 00:02:49,914 --> 00:02:54,120 We need to add the get_project function. 28 00:02:54,120 --> 00:02:57,652 Let's copy the add_project function and make a few changes. 29 00:02:59,468 --> 00:03:02,143 First, we need to rename this get_project. 30 00:03:05,907 --> 00:03:08,965 We're only going to accept a single parameter, the project ID. 31 00:03:13,946 --> 00:03:15,900 Then, we can change the sequel statement to a select. 32 00:03:20,394 --> 00:03:24,222 SELECT all FROM project WHERE 33 00:03:24,222 --> 00:03:30,010 project_id equals our placeholder. 34 00:03:30,010 --> 00:03:32,338 Change the first bindValue. 35 00:03:32,338 --> 00:03:38,260 Instead of $title, we'll use $project_id and this is an int. 36 00:03:41,060 --> 00:03:43,235 Then, we can remove the second bindValue. 37 00:03:44,880 --> 00:03:49,822 Finally, instead of returning true, we need to return the results. 38 00:03:54,890 --> 00:03:58,190 We'll use fetch to fetch a single result from the database. 39 00:03:59,870 --> 00:04:01,970 Now, let's preview the reports page once more. 40 00:04:03,730 --> 00:04:08,223 This time, the header text on the page tells us which report is being run. 41 00:04:14,250 --> 00:04:17,090 You can build reports in many different ways. 42 00:04:17,090 --> 00:04:20,880 They can be as simple or as complex as you choose to make them. 43 00:04:20,880 --> 00:04:25,380 You can allow for deep customization or keep things locked down. 44 00:04:25,380 --> 00:04:28,470 These choices come down to user requirements. 45 00:04:28,470 --> 00:04:31,130 Spend some time creating your own reports. 46 00:04:31,130 --> 00:04:33,250 Add filters change filters and 47 00:04:33,250 --> 00:04:38,290 combine filters to create the report that makes the most sense for you. 48 00:04:38,290 --> 00:04:42,510 Also, make sure you check the teacher's notes associated with this video for 49 00:04:42,510 --> 00:04:45,140 more suggestions and additional resources.