我有一个奇怪的问题:我的 if 和 else 语句都在执行。这是我的代码:
if ($sel_user['name'] != $name) {
$query = "UPDATE owner SET
..."
$result = mysql_query($query);
if (mysql_affected_rows() ==1) {
$query2 = "UPDATE queue_acl SET
..."
$result2 = mysql_query($query2);
if (mysql_affected_rows() ==1) {
$_SESSION['updates_occurred'] = true;
} else {
$_SESSION['updates_occurred'] = false;
}
}
}
if ($sel_user['orgId'] != $orgId) {
$query = "UPDATE ownerOrganization SET
..."
$result = mysql_query($query);
if (mysql_affected_rows() ==1) {
$query2 = "UPDATE queue_acl SET
..."
$result2 = mysql_query($query2);
if (mysql_affected_rows() ==1) {
$_SESSION['updates_occurred'] = true;
} else {
$_SESSION['updates_occurred'] = false;
}
}
}
if ($sel_user['date_expires'] != $colVal[0] ||
$sel_user['admin'] != $colVal[4]) {
$query3 = "UPDATE queue_acl SET
..."
$result3 = mysql_query($query3);
if (mysql_affected_rows() ==1){
$_SESSION['updates_occurred'] = true;
} else {
$_SESSION['updates_occurred'] = false;
}
} else {
$_SESSION['updates_occurred'] = false;
$message = "<i>There were no edits to apply</i>";
}
当我运行它时,正在发送查询并且一切都在正常更新,但是“没有编辑”消息也正在打印
有谁知道为什么?
编辑:我不想使用 elseif 语句;这些事件并不相互排斥。也就是说,如果 $sel_user['name'] != $name AND $sel_user['orgId'] != $orgId,则要求发送两个查询