This works fine except for the first time I open the page and nothing is in the search button. Then I get an error, along with all of the results displayed instead of only when searching:
Undefined variable: searchTerm in C:\xampp\htdocs\index3.php on line 77
<?php
if (isset($_POST['search'])) {
    $searchTerm = $_POST['search'];
}
            
$conn = new mysqli("localhost", "root", "", "Assignment_11");
if ($conn->connect_error) {
    echo 'Connection Faild: '.$conn->connect_error;
} else {
    $sql = "select * from Items where name like '%$searchTerm%'";
    $res = $conn->query($sql);
    while ($row = $res->fetch_assoc()) {
        echo "<br> Name: ". $row["name"]. "   Type: ". $row["type"].  "  Brand:  ".  $row["brand"]. "<br>";
    }
}
 
    