I have problem with the filtering of the results i get from MYSQL database. Its using ajax and are filtering whree variables; city, category and subcategory.
It should work in this chosen order of filtering. First city, then category and then subcategory. Now is the link between city and category not working.
You can see what it looks like now: www.dittarbeid.no
Heres the ajax/Mysql call:
if($category_id=='' && $subcat_id=='' && $town_id!='' && $area_id==''){
$sql="SELECT * FROM joblisting where jobstatus='confirmed' and displaystatus='enable' and paidstatus='Yes' and jobdescription<>'' and Date_Add(paymentdate,INTERVAL 30 day)>$today and area='$area_id' and category='$category_id' order by jobID desc LIMIT 0,39";
And heres how the menu for town is set up and how they fetch the listings:
<select id="city" style="background: url('asstes/barnsje.png') repeat-x center;" onchange="get_jobs_listed(); load_job_listed('area');$('#stown_cat').val(this.value);">
<option value="">Velg By</option>
<?php $area_res= mysql_query("select * from municipality2 order by txt asc");
while($area_row= mysql_fetch_array($area_res)){
if($_SESSION["stown_cat"]==$area_row['id'])
{
echo '<option value="' . $area_row['id'] . '"selected>' . $area_row['txt'] . "</option>";
}
else
echo '<option value="' . $area_row['id'] . '">' . $area_row['txt'] . "</option>";
}
?>
</select>
and category:
<select id="select_category" onchange="load_subcategory(this.value); $('#main_cat').val(this.value);" onclick="get_jobs_listed(this.value); load_job_listed('category')load_subcategory(this.value); ">
<option value="">Velg Kategori</option>
<?php $category_res= mysql_query("select * from category order by categoryName ASC");
while($category_row= mysql_fetch_array($category_res)){
if($_SESSION["main_cat"]==$category_row['category_ID'])
{
echo '<option value="' . $category_row['category_ID'] . '"selected>' . $category_row['categoryName'] . "</option>";
}
else
echo '<option value="' . $category_row['category_ID'] . '">' . $category_row['categoryName'] . "</option>";
}
?>
</select>
and subcategory
<select id="subcategory" style="background: url('asstes/barnsje.png') repeat-x center;" onchange="load_job_listed('subcategory');$('#smain_cat').val(this.value);">
<option value="">Velg Subkategori</option>
<?php $subcategory_res= mysql_query("select * from subcategory order by subcategoryname asc");
while($subcategory_row= mysql_fetch_array($subcategory_res)){
if($_SESSION["smain_cat"]==$subcategory_row['subcategoryID'])
{
echo '<option value="' . $subcategory_row['subcategoryID'] . '"selected>' . $subcategory_row['subcategoryname'] . "</option>";
}
else
echo '<option value="' . $subcategory_row['subcategoryID'] . '">' . $subcategory_row['subcategoryname'] . "</option>";
}
?>
</select>