I have made a very basic search form which fetches name of users from database. It has two problems whenever I hit enter on empty search box it display the whole database instead of showing a error message or just doing nothing like google search box. secondly, i want the search results to appear in dropdown first then a button for whenever a user wants more search results.
Please help in making these changes. any help will be definitely appreciated.
    <h2>Users:</h2><br>
    <?php
    $username="";
    $output = '';
    if (isset($_POST['search'])){
    $search_query = $_POST['search'];
    $search_q = $_POST['search'];
    $search_query = preg_replace("#[^0-9a-z]#i","", $search_query);
    $search_q = preg_replace("#[^0-9a-z]#i","", $search_q);
    $query = mysql_query("SELECT * FROM users WHERE username LIKE '%$search_query%' OR last_name LIKE '%$search_query%'") or die ("Could not search");
    $count = mysql_num_rows($query);
    if($count == 0 ||) {
        $output = 'No Results Found.';
    }
    else{
    while($row = mysql_fetch_array($query)){
        $fname = $row['first_name'];
        $lname = $row['last_name'];
        $id = $row['id'];
    $output .= "<div><a href='profile.php?u=$row[username]'>$fname $lname</a></div>";
    }
    }
    }
    ?>
    <?php echo("$output");?>
      <form method="post" action="search.php" id="search">
        <input type="text" name="search" placeholder="Search..">
 
    