I have my search form, where the cities are fetched from the database, but how can I make the search work when I select some option? I need to get "printed" everything about all houses that are in that particular selected city
HTML Form:
<form action="./server/Search.php" method="post">
<div class="col-auto mt-5">
  
<select name="city" class="form-select" aria-label="Default select example ">
  <option selected disabled>City</option>
  <?php  
    $query = $conn->query("SELECT * FROM `houses`") or die(mysqli_error());
    while($fetch = $query->fetch_array()){
    ?>
  <option value=""><?php echo $fetch['city']?></option>
  <?php
    }
    ?>
</select>
</div>
  <div class="col-auto mt-5">
    <button type="search" name="search" class="btn btn-primary"><i class='bx bx-search-alt-2'></i></button>
  </div>
</form>
Search.php
<?php
    $con= new mysqli("localhost","root","","KBHestate");
    $name = $_post['search'];
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
$result = mysqli_query($con, "SELECT * FROM houses
    WHERE city LIKE '%{$city}%'");
while ($row = mysqli_fetch_array($result))
{
        echo $row['city'];
        echo "<br>";
}
    mysqli_close($con);
    ?>
I don't know how to connect selected option with the query. Is there any way how to handle this the best way possible?
 
     
    