Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
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
it's hard to know which report is actually being run.
Let's change our header text to include more details.
Back in reports.php, find the h1 tag.
Instead of reports, let's use Report on and then, we'll check the filter.
If not is_array $filter then,
we can simply echo All Tasks by Project.
Else, if the filter is an array, we start by displaying the first element,
which is the item we'll be using for our filter.
We'll use the function ucwords to upper case the first letter for title case.
Then, before we add the value, let's add a colon for separation.
Now we can add the switch statement like we did in the function.
If the first element in the filter array equals project, we need to
use the second element of the filter array to pull project details from the database.
We'll create a new function named get_project.
For now, let's just pretend it's already there.
We pass filter 1 and
then, we can echo project title and break.
Let's finish off the switch statement before we add the get_project function.
If the first element of the filter array equals category,
we can simply display the second element of the filter array.
And, if the first element of the filter
array equals date then, we echo filter 1
to filter 2.
Now we can go over to functions.php.
We need to add the get_project function.
Let's copy the add_project function and make a few changes.
First, we need to rename this get_project.
We're only going to accept a single parameter, the project ID.
Then, we can change the sequel statement to a select.
SELECT all FROM project WHERE
project_id equals our placeholder.
Change the first bindValue.
Instead of $title, we'll use $project_id and this is an int.
Then, we can remove the second bindValue.
Finally, instead of returning true, we need to return the results.
We'll use fetch to fetch a single result from the database.
Now, let's preview the reports page once more.
This time, the header text on the page tells us which report is being run.
You can build reports in many different ways.
They can be as simple or as complex as you choose to make them.
You can allow for deep customization or keep things locked down.
These choices come down to user requirements.
Spend some time creating your own reports.
Add filters change filters and
combine filters to create the report that makes the most sense for you.
Also, make sure you check the teacher's notes associated with this video for
more suggestions and additional resources.
You need to sign up for Treehouse in order to download course files.Sign up