Hello i am trying to make a simple if else php statement this is my code but isnt working
$sql = "SELECT UserType from user where Username = '$email'";
$result = mysqli_query($connection, $sql);
if($sql == 'A'){
echo 'Passed';
}else{
echo 'Error';
}
?>
i also tried changin the if($sql == 'A') to if($result == 'A') but still nothing. Am i missing something?
>Solution :
This might help:
$sql = "SELECT UserType from user where Username = '$email'";
if($result = mysqli_query($connection, $sql)){
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
if($row['UserType'] == 'A') {
echo 'Passed';
}
else {
echo 'Error';
}
}