Im making a PM system.
In the recipient field, if you enter
Fox
It will return: Did you mean Megan Fox?
But what if there is more than Megan, having lastname “Fox”, then it will only ask if you meant only one of them.
If there’s more than 1 with lastname “Fox” then i wish it to say:
Who did you mean?
Pammy Fox
Megan Fox
And if there only is 1 with that lastname, i wish it to just say
Did you mean Megan Fox?
(like it does now)
How can i do that?
here’s my code:
$qur = mysql_query("
SELECT id, firstname, lastname,
(firstname = '$firstname' AND lastname = '$lastname') AS full FROM users
WHERE (firstname = '$firstname' AND lastname='$lastname')
OR (firstname LIKE '$firstname%' AND lastname LIKE '$lastname%')
OR firstname LIKE '$firstname%' OR lastname LIKE '$firstname%'
ORDER BY (firstname = '$firstname' AND lastname='$lastname') DESC");
$get = mysql_fetch_array($qur);
if($get["full"] == 1){
echo $get["id"];
}else{
echo "Did you mean: ".$get["firstname"]." ".$get["lastname"]." ?";
}
1 Answer