我正在尝试做一个简单的 if else 语句,但我无法获得预期的结果,并且显然使用了错误的方法。
这就是我所拥有的:
if (!$res7 and !$res8) {output one - this should appear if both $res7 and $res8 are empty}
else if (!$res8) {output two - this should appear if $res8 is empty}
else if (!$res7) {output three - this should appear if $res7 is empty}
输出显示了我想要的,有人可以帮忙修复它吗?谢谢
编辑完整代码: $res7 和 $res8 是 MySQL 查询的结果
$res8 = $pdo->query($query8);
if (empty($res7) && empty($res8)) {
printf("We currently have no reviews for this park or its attractions. If you have been to %s please take a minute to give your feedback. You don't need to register to leave reviews or ratings. Thank you." . PHP_EOL, $row[name]);
}
elseif (empty($res8)) {
printf("We currently have no attraction reviews for this park. If you have been to %s please take a minute to give your feedback. You don't need to register to leave reviews or ratings. Thank you." . PHP_EOL, $row[name]);
}
elseif (empty($res7)) {
printf("<h3>Park Review</h3>We currently have no reviews for this park as a whole. If you have been to %s please take a minute to give your feedback. You don't need to register to leave reviews or ratings. Thank you." . PHP_EOL, $row[name]);
}
else {
printf("all good");
}