Javascript 基于两个选择选项显示mysql的结果数

Javascript 基于两个选择选项显示mysql的结果数,javascript,php,html,mysql,ajax,Javascript,Php,Html,Mysql,Ajax,我有下面的HTML代码,允许我从选择下拉选项中选择两个项目; 现在,在选择这两个项目之后,比如,我选择住宿作为我的表格,坎帕拉作为我的地区,我希望能够自动显示可用的可能结果的总数,例如,找到25个结果 我的问题是,只显示一个选择的结果,而另一个选择显示为未定义通知。请帮忙 <!-- here is the html script for selecting options --> <form id="analysis_formId" method="POST">

我有下面的HTML代码,允许我从选择下拉选项中选择两个项目; 现在,在选择这两个项目之后,比如,我选择住宿作为我的表格,坎帕拉作为我的地区,我希望能够自动显示可用的可能结果的总数,例如,找到25个结果

我的问题是,只显示一个选择的结果,而另一个选择显示为未定义通知。请帮忙

<!-- here is the html script for selecting options -->    

<form id="analysis_formId" method="POST">

<label>select form</label>
<select id="selectformId" name="selectform" class="select_elements">
<option value="afc">accommodation form</option>
<option value="rtt">tour and travel form</option>   
</select>

<label>select district</label>

<select id="selectdistrictsId" name="selectdistricts" class="select_elements">
<option value="alldistricts">All districts</option>
<option value="kampala">kampala</option>
<option value="wakiso">wakiso</option>   
</select>        
</form>

<!-- displaying results from count.php -->
<p><span id="inspection_result"></span></p>
下面是count.php,用于从MySQL查询结果


此查询可能没有结果,请选中:

if (!empty(display2) ){
..... // DO something
}

彼得,我已经编辑过了,它本来不应该在那里的…谢谢你指出这一点。来吧,伙计们,请帮忙。我花了很长时间才想出解决这个问题的办法。
if($_POST) 
{
$formtype     = strip_tags($_POST['selectform']);
$selectdistricts     = strip_tags($_POST['selectdistricts']);


$fetchallforms22 = $conn->prepare("select count(indexId) as numafcrtt2 
from registered_companies where company_form_type=:formtype and company_district=:selectdistricts");

$fetchallforms22->execute(array(':formtype'=>$formtype, ':selectdistricts'=>$selectdistricts));

$display22 = $fetchallforms22->fetchObject();           

if($display22){

echo $display22->numafcrtt2." "."results available";
}
else
{
echo $display22->numafcrtt2." "."results available";
}
}//POST
if (!empty(display2) ){
..... // DO something
}