仅在用户在数据库中排名为= 2
时才尝试回显即使它的等级为0而且我不知道为什么,它也会回响它。这是我的代码。
<?php
$query299 = "SELECT * from users WHERE username = '" . $_SESSION['user']['username'] . "'";
$stmt2 = $db->prepare($query299);
$stmt2->execute();
$row2 = $stmt2->fetch();
if($row2['rank'] = 2) {
echo '
<li>
<a href="admin.php">
<i class="fa fa-cog"></i>
<span>Admin</span>
</a>
</li>
';
}
?>
答案 0 :(得分:0)
请看这里的陈述,
if($row2['rank'] = 2) { ...
^ you're doing assignment, not comparison
应该是,
if($row2['rank'] == 2) {