I have a code to check user data already exist in mysql by mysqli like this :
$SQL = "SELECT users.email,users.handle,userprofile.mobile FROM users,userprofile
WHERE users.email =? OR users.handle =? OR userprofile.mobile=?";
if ($stmt = $mysqli->prepare($SQL)) {
$stmt->bind_param("sss", $email,$username,$mobile);
$stmt->execute();
if($stmt->num_rows){
$result = $stmt->get_result();
$row = $result->fetch_array(MYSQLI_NUM);
if($row[0] ==$email){echo 'email exist';}
if($row[1] ==$username){echo 'username exist';}
if($row[2] ==$mobile){echo 'mobile exist';}
}
else{
echo 'OK';
}
if works when the user data already exist.
but if user data does not exist , the else
does not work!
why?