added filter

This commit is contained in:
Joshua Perry 2023-01-25 16:33:08 +00:00
parent 3b9791888c
commit d574a28c1d
2 changed files with 17 additions and 1 deletions

View File

@ -25,8 +25,14 @@ class Jobs {
if ($cat == null) {
return $this->notFound();
}
else {
if (isset($_GET['filter'])) {
$this->vars['jobs'] = $this->jobsTable->find('categoryId', $cat[0]->id, "location", $_GET['filter']);
}
else {
$this->vars['jobs'] = $this->jobsTable->find('categoryId', $cat[0]->id);
}
$this->vars['heading'] = $cat[0]->name;
return ['template' => 'category.html.php',
'title' => 'Jo\'s Jobs- '. $_GET['page'],

View File

@ -7,6 +7,16 @@
<section class="right">
<h1> <?=$heading?> Jobs</h1>
<form method="get" action="/jobs/category">
<label for="filter">Filter:</label>
<select name="filter">
<?php foreach ($jobs as $job) { ?>
<option value="<?=$job->location?>"><?=$job->location?></option>
<?php } ?>
</select>
<input type="hidden" name="page" value="<?=$_GET['page']?>" />
<input type="submit" name="submit" value="filter" />
</form>
<ul class="listing">
<?php require 'job.html.php';?>
</ul>