My PHP search code always returns 0 records, even when the record exists.
Any help would be appreciated.
<?php
$conn = new mysqli("localhost", "root", "xxxxxx", "SAVR1984");
$Surname =$_POST['Surname'];
$Maidenname = $_POST['Maidenname'];
$Firstname = $_POST['Firstname'];
$sql="SELECT * FROM 1984 WHERE Surname LIKE $Surname AND Maidenname LIKE '%".$Maidenname."%' AND Firstname LIKE '%".$Firstname."%'";
If(! $conn ) {
die('Could not connect: ' . mysqlerror());
}
$result = $conn->query($sql);
if ($result->num_rows > 0){
while ($row = $result->fetch_assoc() ){
echo $row["Surname"] . " " . $row["Maidenname"] . " " . $row["Firstname"] . " " . $row["ID"] . " " . $row["Occupation"] . " " . $row["Address"] . " " . $row["Notes"] . "<BR>";
}
} else {
echo "0 records found";
}
$conn->close();
?>