在列表中显示状态为“user”或“admin”的所有用户

I have an issue to get users data by their status (Admin/User).

I don't want to show an admin on the list, so help me...

 $status= 'user';

// I've tried this, but it didn't helped

$sql = "SELECT * FROM users WHERE status = $status";

$result = $conn->query($sql);

if ($result->num_rows >0) {


while($row[] = $result->fetch_assoc()) {

 $tem = $row;

 $json = json_encode($tem);

 }

} else {
 echo "Error";
}
 echo $json;

$conn->close();
 }
?>

You need to put $status in the single quotation marks


if

$status = 'user';

then:

$sql = "SELECT * FROM users WHERE status = '$status'";

$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {


while($row = mysqli_fetch_assoc($result)) {



 $json = json_encode($row);

 }

} else {
 echo "Error";
}
 echo $json;

$conn->close();
 }
?>