title: Fetch data from mysql database using drop down list and then use search function to filter data from selected drop down list option
body: <p>I want to comebine the use of a drop down list (with filters/options) with a search function (a search bar and a "Ok" button).</p>
  
  <p>When I select a filter/option in the drop down list, as for example "Team". The drop down
  list then should be aware of that the list has changed to filter/option "Team".
  After this, I use the search function  where I input the search term, like "USA" then press
  the Ok-button.
  Once the Ok-button is pressed, a sql-query like: SELECT * FROM mytable WHERE Team = 'USA';
  is generated to fetch all the matched rows in the db "mytable".</p>
  
  <ol>
  <li>Select a filter, "Team".</li>
  <li>Select a team, "USA".</li>
  <li>Fetch matched rows with relevant data from the db mytable.</li>
  </ol>
  
  <p>Hope I made myself understood better, thank you all for your time!</p>
  
  <p>This is the code I have:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt; 
          &lt;title&gt;AiFind&lt;/title&gt;
          &lt;link rel="stylesheet" href="Style.css"&gt;
          &lt;script src="logic.js"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;AiFind&lt;/h1&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  
  
  &lt;?php
  
  include "connection.php";
  
  $sql = "SELECT * FROM mytable";
  
  if (isset($_POST['search'])) {
  
      $search_term = mysql_real_escape_string($_POST['search_box']);
  
      $sql .= " WHERE F_ar = '$search_term' ";
      $sql .= " OR Postnr = '$search_term' ";
      $sql .= " OR Postort = '$search_term' ";
      $sql .= " OR Vardgivare = '$search_term' ";
      $sql .= " OR Team = '$search_term' ";
      $sql .= " OR Orsak = '$search_term' ";
      $sql .= " OR Planerat_datum = '$search_term' ";
      $sql .= " OR fran = '$search_term' ";
      $sql .= " OR AAA_diam = '$search_term'; ";
  }
  
  $query = mysql_query($sql) or die(mysql_error());
  
  ?&gt;
  
  &lt;form name="Select_filter" method="POST" action="VGR_data_display.php"&gt;
  &lt;select id="dropdown" name="filter"&gt;
  &lt;option value=""&gt;&lt;/option&gt;
  &lt;option value="1"&gt;ID&lt;/option&gt;
  &lt;option value="2"&gt;Alder&lt;/option&gt;
  &lt;option value="3"&gt;Postnummer&lt;/option&gt;
  &lt;option value="5"&gt;Postort&lt;/option&gt;
  &lt;option value="6"&gt;Vårdgivare&lt;/option&gt;
  &lt;option value="7"&gt;Planerat Datum&lt;/option&gt;
  &lt;option value="8"&gt;Status&lt;/option&gt;
  &lt;option value="9"&gt;AAA_diameter&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  
  
  &lt;!--search bar for search term input --&gt;
  &lt;form name ="search_form" method="POST" action="VGR_data_display.php"&gt;
  
      &lt;input id="search_box" type="text" name="search_box" value="" /&gt;
      &lt;input id="submit" type ="submit" name ="search" value ="Ok"&gt;
  
  &lt;/form&gt;
  
  &lt;table style="margin:auto;" id="table" border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;ID&lt;/th&gt;
  &lt;th&gt;F_ar&lt;/th&gt;
  &lt;th&gt;Postnr&lt;/th&gt;
  &lt;th&gt;Postort&lt;/th&gt;
  &lt;th&gt;Vardgivare&lt;/th&gt;
  &lt;th&gt;Team&lt;/th&gt;
  &lt;th&gt;Orsak&lt;/th&gt;
  &lt;th&gt;Planerat_datum&lt;/th&gt;
  &lt;th&gt;fran&lt;/th&gt;
  &lt;th&gt;AAA_diam&lt;/th&gt;
  &lt;/tr&gt;
  
  
  &lt;?php while($row = mysql_fetch_array($query)) { ?&gt;
    &lt;tr&gt;
    &lt;td&gt;&lt;?php echo $row['id']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['F_ar']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['Postnr']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['Postort']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['Vardgivare']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['Team']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['Orsak']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['Planerat_datum']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['fran']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['AAA_diam']; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
  &lt;?php } ?&gt;
  </code></pre>