我有一个函数,它根据所述变量的内容输出某种颜色的变量,但是它正在输出与IF语句相同的响应,即使IF语句不是真的
function info($ride) {
$query = mysql_query("SELECT * FROM `qtd` WHERE `name` = '$ride'");
$rideinfo = mysql_fetch_array($query);
$time = $rideinfo["time"];
if ($time != "Unavailable" || $time != "CLOSED") {
echo "<center><font color=\"228B22\"><b>$time</b></font></center>";
}
if ($time == "Unavailable" || $time == "CLOSED") {
echo "<center><font color=\"B22222\">$time</font></center>";
}
}
即使$time
或$time = "Unavailable"
的值
"CLOSED"
var newElement = element.parent().clone(true,true).html();
答案 0 :(得分:5)
你必须改变你的第一个条件,因为它总是true
:
if ($time != "Unavailable" && $time != "CLOSED"){echo "<center><font color=\"228B22\"><b>$time</b></font></center>";}
if ($time == "Unavailable" || $time == "CLOSED"){echo "<center><font color=\"B22222\">$time</font></center>";}
在这种情况下,您还可以将其更改为if-else语句:
if ($time != "Unavailable" && $time != "CLOSED"){
echo "<center><font color=\"228B22\"><b>$time</b></font></center>";
} else {
echo "<center><font color=\"B22222\">$time</font></center>";
}