douhuijun3776 2015-08-17 23:16
浏览 18

我的if语句出了什么问题? 我是否添加了和/或正确?

If $a3['rentsale'] is either A) empty or B) equal to the form entry for rentsale then this part is true. It returns TRUE (manage.php?result=True) when just this part of the if statement is there. But then when I added the second part (&&) to the if statement to also see if $a3['propertytype'] is either A) empty or B) equal to the form entry for propertytype chosen it returns FALSE (manage.php?result=False). When just the first part was there and also when the second part was added, on the form submission I selected/input the option so they both equal the sql entries ($a3[]).

What have I done wrong?

$q3 = "select * from alerts";
$r3 = mysql_query($q3) or die(mysql_error());
$a3 = mysql_fetch_array($r3);

if(($a3['rentsale'] == '' || $a3['rentsale'] == $_POST['rentsale']) && ($a3['propertytype'] == '' || $a3['propertytype'] == $_POST['propertytype'])) {

header("location:manage.php?result=True");  
exit(); 

}
else {
header("location:manage.php?result=False");
exit();
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line