What I've been trying to do for several hours now is simply check the column 'user' of a table 'nonpersonal' to match my variable '$recipient'.
I thought there must be a much easier way than selecting the whole column 'user', putting it through a while loop with fetch_assoc() and only then check if there is a 'user' that matches '$recipient'.
If yes, please tell me! :) If not, what would be the most efficient way? I tried in_array(), e.g., but couldn't get it to work. I guess I'm missing the basic understanding of how the query($sql) fills $result, which I tried to find out as well..
$sql = "SELECT user FROM nonpersonal WHERE user LIKE '$recipient'";
$result = $conn->query($sql);
if($recipient == $result)) {
echo "<br> This recipient does exist."
} else {
echo "<br> This recipient does not exist. Try again.<br>";
}
Thank you very much in advance!
Aucun commentaire:
Enregistrer un commentaire