I have a table of records which contains first name, last name, mobile number, email of persons details. I want to check each time when I get these values passed from front end page to check whether first name matches to a record in Database with the same first name and also for last name and so on.. So if all four columns match to the parameters getting from front page some how then the matching percentage is 100%. Likewise if three parameters match then it'll be 75% and so on...
attempt...
$firstName = 'peter';
$lastName = 'cetera';
$phoneNumber = '0384849494';
$emailAddress = 'peter@abc.com';
$matchPercentage;
$stmt = $mysqli->prepare("SELECT
person.firstName,
person.lastName,
person.mobileNo,
person.email
FROM
person
LEFT OUTER JOIN reg_person ON (person.personId = reg_person.personId)
AND (person.messageid = reg_person.messageId)
AND (person.firstName = reg_person.firstName)
AND (person.lastName = reg_person.lastName)
AND (person.mobileNo = reg_person.mobile)
AND (person.email = reg_person.email)
WHERE
person.firstName = ? AND
person.lastName = ? AND
person.mobileNo = ? AND
person.email = ?");
$stmt->bind_param("ssss",$firstName,$lastName,$phoneNumber,$emailAddress) or die($mysqli->error);
$stmt->execute();
$stmt->bind_result($firstName,$lastName,$mobileNo,$email);
$stmt->store_result();
$num_of_rows = $stmt->num_rows;
if($num_of_rows > 0){
$matchPercentage = '100%';
}else{......
will it take 16 mysql queries to do it?... or is there a simpler way?