<?php
include "conn.php";
include "session.php";
// Define $username and $password
$n1 = $_POST['Name'];
$sql = "SELECT *FROM myDB.Mynew WHERE Fname like '%".$n1."%' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    echo '<table>';
    echo '<tr>';
    echo'<th>First Name</th>
        <th>Last Name</th>
        <th>Email</th>
        <th>Password</th>';
    echo'<tr>';
    while ($row = $result->fetch_assoc()) {
        echo '<tr>';
        echo '  <td>' . $row["firstname"] . '</td>';
        echo '  <td>' . $row["lastname"] . '</td>';
        echo '  <td>' . $row["email"] . '</td>';
        echo '  <td>' . $row["password"] . '</td>';
        echo '  </tr> ';
    }
    echo'</table>';
} else {
    echo "<br> No Record Found to display";
}
When I run this code I get the following notice:
Notice: Trying to get property of non-object at line 14 which is "if ( $result->num_rows >0) {"
 
     
     
     
    