我有这 3 个 if 语句,它们根据变量中的值将其放入一列或另一列。但由于某种原因,即使 if 语句应该为假,它也总是只使用 3 个中的一个。我把代码放在下面。谢谢你的帮助。
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
// error happened
print(0);
}
mysql_select_db('test');
// sanitize the value
$value = mysql_real_escape_string($_GET['uname']);
$id = mysql_real_escape_string($_GET['id']);
if($value == "Paid" || "Waiting on Payment"){
$sql = "UPDATE test SET payment='$value' WHERE id='$id'";
}
if($value == "Repaired" || "Waiting on Repairs"){
$sql = "UPDATE test SET repair='$value' WHERE id='$id'";
}
if($value == "With Student" || "Awaiting Pickup"){ //Always uses this one for somereason unknown to me..
$sql = "UPDATE test SET returned='$value' WHERE id='$id'";
}
// start the query
// check if the query was executed
if(mysql_query($sql, $link)){
// everything is Ok, the data was inserted
print(1);
echo $sql;
} else {
// error happened
print(0);
}
?>