I have a search bar wich finds a job and I want to give the opportunity to filter the result by selected city or/and category.
This is my PHP code so far:
if (isset($_POST['search'])) {
$job = $_POST['search'];
$city = $_POST['city'];
$category = $_POST['category'];
$query ="SELECT jobname, city, category FROM table_jobs WHERE jobname LIKE '%$job%'";
if($city != "Chose City") {
$query .=" AND city LIKE '%$city%'";
}
if($ategory != "Chose Category"){
$query .=" AND category LIKE '%$category%'";
}
$sql = mysql_query($query);
$count = mysql_num_rows($sql);
if ($count == 0) {
$output = "No results!";
} else {
while($row = mysql_fetch_array($query)) {
$titlu = $row['jobname'];
$companie = $row['numefirma'];
$oras = $row['numeoras'];
$domeniu = $row['numedomeniu'];
$output .=<<<HTML
<table id="anunt">
<tr>
<td class='left'><a href='' style="color: blue">$titlu</a><br>Companie: $companie<br>Domeniu: $domeniu</td>
<td class='right'>$oras</td>
</tr>
</table>
HTML;
}
}
}
The search bar looks like this
How can I make my filter lists work? I have my city tables in my database and category table (with work categories like IT software, marketing etc)