I’m new to php . Please help me with this problem.
<?php include 'config.php';
$output = ' ';
if (isset($_POST['query'])) {
$search= $_POST['query'];
$stmt=$conn->prepare("SELECT * FROM live_search WHERE first_name LIKE CONCAT('%'.?.'%') OR last_name LIKE CONCAT('%'.?.'%')");
$stmt->bind_param("ss",$search,$search);
}
else {
$stmt = $conn->prepare("SELECT * FROM live_search");
}
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows>0) {
$output="<tr>
<th>#</th>
<th>first name</th>
<th>last name</th>
<th>email</th>
<th>Gender</th>
</tr>
<tbody>";
while ($row=$result->fetch_assoc()) {
$output .= " <tr>
<td> ". $row['id'] ." </td>
<td> ". $row['first_name'] ." </td>
<td> ". $row['last_name'] ." </td>
<td> ". $row['email'] ." </td>
<td> ". $row['gender'] ." </td>
</tr> ";
}
$output .= "</tbody>";
echo $output;
}
?>