Filter by Project

Learn how to handle a form with the GET method.

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) : ?>
          
...