I currently have a list of items that are stored in a database that are retrieved and displayed using a foreach.
foreach($files as $file){
echo'<div class="col-lg-9" id="file-'.$file['id'].'">
<div class="file-list-item first" id="">
<img class="file-image" height="120px" width="180px" src="'.$file['image_url'].'" />
<div class="file-text">
<h3><strong>'.$file['name'].'</strong></h3>
Submitted by: '.$file['submitter'].'<br/>
Author: '.$file['author'].'<br />
Category: '.ucfirst($file['subcategory']).'<br />
Description: '.substr($file['description'],0,45).'...
</div>
<div class="download">
<a target="_blank" href="'.$file['download_url'].'" class="btn-success btn btn-default">Download</a>
<a href="'.baseurl.'/broken.php?id='.$file['id'].'" class="btn btn-default">Report as Broken</a><br /><br />';
if($file['is_broken']){
echo '<span class="broken"><i data-toggle="tooltip" data-placement="left" id="broken" title="This file has been reported as broken and is awaiting review." class="fa fa-warning fa-2x"></i></span>';
}
echo '
</div>
</div>
</div>';
};
What would be the best way to filter these results using a drop down menu? The value I wish to filter by is `$file['subcategory']
So, I wish for various categories to be displayed in a dropdown menu, and once the value of this is changed, I wish for the page to refresh and display only the results the user desires.
Many thanks.