Search⌘ K
AI Features

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.

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:

  1. Create a basic form in views/reports.php.
  2. Edit the controller and the model for the “Filter” feature.
  3. 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
...