我对从MYSQL数据库中获得的结果进行过滤有问题。它使用ajax并过滤whree变量;城市,类别和子类别。
它应该按照这个选择的过滤顺序工作。第一个城市,然后是类别,然后是子类别。现在城市和类别之间的联系不起作用。
您可以看到它现在的样子:www.dittarbeid.no
继承人ajax / Mysql电话:
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";
以下是如何设置城镇菜单以及如何获取列表:
<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>
和类别:
<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>
和子类别
<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>