I'm using Mysqli OO to search the database for 2 specific values using the MySQL statement CASE. If both values are found then it will return the value 'true', if only one is found the value is 'false', if neither are found then the result is neither. Anyway I've got this working but my problem is I need it to also display the values that are related in the column.
Okay so when I run the code it should display as:
$query = "SELECT 'userName','email','code',
WHEN (email=? AND code=?) THEN 'true'
WHEN (email=?) THEN 'false'
END AS answer
FROM users WHERE email=?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("ssss", $email,$code, $email,$email);
$email = $mysqli->real_escape_string($email);
$code = $mysqli->real_escape_string($code);
echo "User: ".$user." Email: ".$email." Code: ".$code." Answer: ".$answer;
But instead it displays it as:
User: ryan Email: local@localhost Code: 12 Answer: true
So I think the error is more to do with the SQL side of it but not sure, I'm stuck and would like some help. Thanks
User: userName Email: email Code: code Answer: true
BTW I have posted it in the PHP area as well just for the simple reason I'm not entirely sure which part it is, so sorry if I'm not allowed to do this