Filter by Project
Understand how to implement project-based filtering in a PHP CRUD app. Learn to create a selection form, adjust the controller to receive filter input, and modify SQL queries to retrieve filtered task reports effectively.
We'll cover the following...
We'll cover the following...
In this lesson, we’ll focus on filtering data by project. This is the workflow that we’ll follow to filter the data project-wise:
- Create a basic form in
views/reports.php. - Edit the controller and the model for the “Filter” feature.
- Run the application.
Basic implementation
Let’s create a form in our view with a list of all the projects:
<p>Filter by</p>
<form method="get">
<select name="filter" id="project">
<option value="">Select one</option>
<?php foreach ($projects as $project) : ?>
<option ...