How can you determine if a search query in PHP returned no results and prevent displaying the table header?

To determine if a search query in PHP returned no results and prevent displaying the table header, you can check the number of rows returned by the query. If the number of rows is zero, you can set a flag to prevent displaying the table header. This can be achieved by using the `mysqli_num_rows()` function to get the number of rows returned by the query.

// Execute the search query
$result = mysqli_query($connection, $query);

// Check if the query returned no results
if(mysqli_num_rows($result) == 0) {
    $noResults = true;
} else {
    $noResults = false;
}

// Display the table header only if there are results
if(!$noResults) {
    echo "<table>";
    echo "<thead>";
    echo "<tr>";
    echo "<th>Column 1</th>";
    echo "<th>Column 2</th>";
    echo "</tr>";
    echo "</thead>";
    // Display the table rows here
    echo "</table>";
}