I have the following form with three search fields. Two text inputs (keyword and distance) and a dropdown list (transportation).
My search function works with the keyword text input, but not the other two fields. I can see that data is being output when I "echo", but it won't actually search for those terms.
    <form action="searchresults.php" method="POST">
  <h3> Keyword </h3>
    <input type="text" name="keyword-search">
  <h3> Primary Function </h3>
  <?php
  $sql = "SELECT pf_id, primary_function FROM primary_function ORDER BY pf_id;";
  $result = mysqli_query($conn, $sql);
  echo "<select name='function-search' id = 'function-search'>";
  echo '<option value=""></option>';
  while ($row = mysqli_fetch_assoc($result)) {
                unset($id, $name);
                $id = $row['pf_id'];
                $name = $row['primary_function'];
                echo '<option value="'.$name.'">'.$name.'</option>';
              }
  echo "</select>";
  ?>
  <h3> Distance </h3>
    within <input type="text" name="distance-search"> miles of PCC
    <br>
    <button type="submit" name="submit-search">Search</button>
</form>
The following is where the data is being pushed to.
    <?php
if (isset($_POST['submit-search'])) {
$functionSearch = mysqli_real_escape_string($conn, $_POST['function-search']);
$keySearch = mysqli_real_escape_string($conn, $_POST['keyword-search']);
$distanceSearch = mysqli_real_escape_string($conn, $_POST['distance-search']);
$sql = "SELECT * FROM resource WHERE resource_name LIKE '%$keySearch%'
OR  description LIKE '%$keySearch%' OR username LIKE '%$keySearch%'
OR primary_function LIKE '%$keySearch%'
OR distance_in_miles LIKE '%$keySearch%'
ORDER BY distance_in_miles";
$result = mysqli_query($conn, $sql);
$queryResult = mysqli_num_rows($result);
// Checking for search result page errors
//echo $result;
echo $queryResult;
// echo $functionSearch;
if ($queryResult > 0){
    while ($row = mysqli_fetch_assoc($result)) {
      echo "<tr><td>". $row['resource_id'] ."</td><td>". $row['resource_name'] ."</td><td>". $row['username'] ."</td><td>". "$" .$row['cost_in_usd'] ."/". $row['cost_per'] ."</td><td>". $row['distance_in_miles'] ."</td></tr>";
    } echo "</table>";
  } else {
    echo "<br>No results matching your search";
  }
}
?>
 
    