我有一个复选框过滤器,其中有两个过滤器框用于公司名称,另一个用于工资。有一个过滤器按钮。用户可以查看一个或多个公司名称,但只能选择一个薪水。当用户选择薪水并单击过滤器按钮时,查询工作正常。但是如何查询哪个用户可以选择公司名称或薪水或两者。
$(document).delegate('#filter_button','click',function(){
var sal=$('#sal input:checkbox:checked').map(function(){return
$(this).val();}).get()
var emp=$('#emp input:checkbox:checked').map(function(){return
$(this).val();}).get()
$.ajax({
type:'POST',
url:'autoload_jobs.php',
data:{'salary':JSON.stringify(sal),'employer':JSON.stringify(emp)},
success:function(data)
{
$("#all").hide();
$("#result").show();
$("#result").html(data);
}
});
});
$sql_sal="select *,fe.id as jid,fe.job_title,fe.job_category,fe.exp_min,fe.exp_max,e.emp_company,e.emp_company,fe.job_desc,group_concat(DISTINCT jl.loc SEPARATOR ', ') as loc from jobs
as fe INNER JOIN employer as e ON fe.emp_id=e.emp_id INNER JOIN
`jobs_skills` as js ON fe.id=js.j_id INNER JOIN `job_loc` as jl ON
fe.id=jl.j_id INNER JOIN
`employer_details` as eds ON fe.emp_id=eds.emp_id where ";
if(isset($_POST['salary'])){
?><script>$('.all').hide();</script><?php
$sal=$_POST['salary'];
list($mins,$maxs)=explode(".",$sal,'2');
$sql_sal .=" fe.max_salary BETWEEN '$mins' AND '$maxs' GROUP BY
jl.j_id";
}
if(isset($_POST['employer'])){
?><script>$('.all').hide();</script><?php
$emp=$_POST['employer'];
$sql_sal .="AND e.emp_id='$emp' ";
}
$sql_sal .=" GROUP BY jl.j_id";