Naming Reports4:45 with Alena Holligan
The report page is looking good. But it's hard to know which report is actually being run. Let's change our header text to include more detail.
fetch() Fetches a single row from a result set
fetchAll() Returns an array containing all of the result set rows
- Allow users to enter their own date range.
- Combine Project with Date Range
- Combine Category with Date Range.
- Sort Tasks by Date
- Sort Tasks by Time
- Group Tasks by Day
- Group Tasks by Week
Additional Course Suggestions
This course covers powerful SQL features in helping you answer more interesting questions about your data.
Data Science Basics: Uses Python but the Principles Apply
This course will follow the basic procedures of conducting data science work, namely selecting and describing data, and munging it into a communicable form. At the end of this course, students will be able to pick a small dataset available online and, using Python language, quickly calculate descriptive statistics and show their results with basic charts and tables.
The report page is looking good but 0:00 it's hard to know which report is actually being run. 0:02 Let's change our header text to include more details. 0:06 Back in reports.php, find the h1 tag. 0:10 Instead of reports, let's use Report on and then, we'll check the filter. 0:14 If not is_array $filter then, 0:28 we can simply echo All Tasks by Project. 0:33 Else, if the filter is an array, we start by displaying the first element, 0:46 which is the item we'll be using for our filter. 0:51 We'll use the function ucwords to upper case the first letter for title case. 0:56 Filter 0. 1:04 Then, before we add the value, let's add a colon for separation. 1:07 Now we can add the switch statement like we did in the function. 1:13 If the first element in the filter array equals project, we need to 1:26 use the second element of the filter array to pull project details from the database. 1:33 We'll create a new function named get_project. 1:39 For now, let's just pretend it's already there. 1:42 We pass filter 1 and 1:48 then, we can echo project title and break. 1:54 Let's finish off the switch statement before we add the get_project function. 2:03 If the first element of the filter array equals category, 2:08 we can simply display the second element of the filter array. 2:15 And, if the first element of the filter 2:25 array equals date then, we echo filter 1 2:30 to filter 2. 2:39 Now we can go over to functions.php. 2:46 We need to add the get_project function. 2:49 Let's copy the add_project function and make a few changes. 2:54 First, we need to rename this get_project. 2:59 We're only going to accept a single parameter, the project ID. 3:05 Then, we can change the sequel statement to a select. 3:13 SELECT all FROM project WHERE 3:20 project_id equals our placeholder. 3:24 Change the first bindValue. 3:30 Instead of $title, we'll use $project_id and this is an int. 3:32 Then, we can remove the second bindValue. 3:41 Finally, instead of returning true, we need to return the results. 3:44 We'll use fetch to fetch a single result from the database. 3:54 Now, let's preview the reports page once more. 3:59 This time, the header text on the page tells us which report is being run. 4:03 You can build reports in many different ways. 4:14 They can be as simple or as complex as you choose to make them. 4:17 You can allow for deep customization or keep things locked down. 4:20 These choices come down to user requirements. 4:25 Spend some time creating your own reports. 4:28 Add filters change filters and 4:31 combine filters to create the report that makes the most sense for you. 4:33 Also, make sure you check the teacher's notes associated with this video for 4:38 more suggestions and additional resources. 4:42
You need to sign up for Treehouse in order to download course files.Sign up