if(isset($_POST['id']))
{
// id to search
$id = $_POST['id'];
// Fetch Data From DataBase
$sql ="SELECT * , DATE_FORMAT(birthdate, '%d/%m/%Y') AS birthdate FROM `personal_info` WHERE `personal_id_number` = $id ORDER BY birthdate DESC";
$result = $conn -> query($sql);
if ($result -> num_rows <> 0) {
while ( $row = $result -> fetch_assoc() ) {
echo "<tr><td>" . $row["person_name"]
. "</td><td>". $row["personal_id_number"]
. "</td><td>". $row["birthday"]
. "</td><td>" . $row["adress"]
. "</td><td>" . $row["phone_number"]
. "</td><td>" . $row["email"]
. "</td><td colspan='3' class='more fit'>"
. $row["more_info"]
. "</td></tr>";
}
}
This search field is doing his job only if search criteria is some field in database that have numbers, like "personal_id_number" and "phone_number".
Otherwise, If I put "personal_name_ as a search criteria, I would get an error "Notice: Trying to get property 'num_rows' of non-object ".