php form表单相关问题
php代码如下:
<!-- 类别选择框 -->
<form method ="get" action="/show_by_Price.php" target="showframe">
<select name="categories" onchange="submit()">
<option value="pleaseChoose" selected="selected">Please Choose</option>
<option value="Electronic">Electronic</option>
<option value="Book" >Book</option>
<option value="Fashion">Fashion</option>
</select>
</form>
<b font='Times New Roman'>Price:</b>
<br>
<!-- 产品价格选择框 -->
<form method ="get" action="/show_by_Price.php" target="showframe">
<select name="price" onchange="submit()">
<option value="Please_Choose" selected="selected">Please Choose</option>
<option value="hight">more than 2000</option>
<option value="middle" >1000~2000</option>
<option value="low">less than 1000</option>
</select>
</form>
show_by_Price.php关键处理代码如下:
if ($_GET[categories]=='pleaseChoose'){
if ($_GET[price]=='Please_Choose'){
//$result_price=null;
echo Please_choose ;
}
else {
if ($_GET[price]=='hight'){
echo p_H ;
$result_price = mysql_query("SELECT * FROM Product where Price>2000");
}
elseif ($_GET[price]=='middle'){
echo p_M ;
$result_price = mysql_query("SELECT * FROM Product where Price<2000 && Price>1000");
}
else{
echo p_L ;
$result_price = mysql_query("SELECT * FROM Product where Price<1000");
}
}
}
else
{
if ($_GET[price]=='Please_Choose'){
echo C_P ;
$result_price = mysql_query("SELECT * FROM Product where Category='$_GET[categories]'");
}
else{
if ($_GET[price]=='hight'){echo C_H;
$result_price = mysql_query("SELECT * FROM Product where Price>2000 and Category='$_GET[categories]'");
}
elseif ($_GET[price]=='middle'){echo C_M;
$result_price = mysql_query("SELECT * FROM Product where (Price<2000 && Price>1000 )and Category='$_GET[categories]'");
}
else{echo C_L;
$result_price = mysql_query("SELECT * FROM Product where Price<1000 and Category='$_GET[categories]'");
}
}
}
为什么两个框都选择的是Please Choose的时候 ,执行的是echo p_L ;
$result_price = mysql_query("SELECT * FROM Product where Price<1000");
而不是echo Please_choose ;
求高手指点
------解决方案--------------------当一个表单提交时,另一个表单的值是未设置状态,而不是你想的等于pleaseChoose,所以,你的后台逻辑判断有误,你再好好看看。
------解决方案--------------------
都跟你说啦。放入一个form当中去,事情就好办多了。