title: Search bar with dropdown catagories. Search results not pulling from database and showing
body: <p>So I have search bar that I'm hoping searches records in a mysql database and show them on a webpage. It should allow the user to choose the field they are searching under but it is is not showing the records the other end. Any ideas?</p>
  
  <p>html:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;form action='recordresult.php' method='POST' name='form_filter' class="form-style-1" &gt;    
      &lt;b&gt;Search&lt;/b&gt;&lt;br&gt;
      &lt;select name="selectVal"&gt;
          &lt;option value="category" &gt;Select a category&lt;/option&gt;
  &lt;option value="first_name"&gt;First Name&lt;/option&gt;
  &lt;option value="surname"&gt;Surname&lt;/option&gt;
  &lt;option value="address"&gt;Address&lt;/option&gt;
  &lt;option value="phonenumber"&gt;Telephone&lt;/option&gt;
      &lt;/select&gt;
      &lt;input type='text' name='search' placeholder='Enter text here...'&gt;&lt;br&gt;
      &lt;input type='submit' value='Send'&gt;  
  &lt;/form&gt;
   </code></pre>
  </div>
  </div>
  </p>
  
  <p>PHP</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  include("config.php");
  $link = mysqli_connect($server, $db_user, $db_pass)
  or die ("Could not connect to mysql because ".mysqli_error($link));
  
  // select the database
  mysqli_select_db($link, $database)
  or die ("Could not select database because ".mysqli_error($link));
  
    $search         = isset($_POST['search'])       ? htmlspecialchars(trim($_POST['search']))      : null;
      $catLocation    = isset($_POST['selectVal'])    ? htmlspecialchars(trim($_POST['selectVal']))   : null;
      $query          = "SELECT * FROM $table WHERE ";
  
      //YOU INDICATED YOU'D NEED TO RUN THE SEARCH-QUERY IF THE SEARCH-TERM AND SEARCH-SCOPE ARE DEFINED IE: NOT NULL; HOWEVER IF THE SEARCH TERM IS NOT GIVEN, YOU SELECT EVERYTHING IN THAT TABLE... (BAD PRACTICE, THOUGH)
      if($catLocation){
          if($search){
              if($catLocation == "category"){
                  $query .= " category LIKE '%" . $search . "%'";
              }
     else if($catLocation == "first_name"){
                  $query .=  "first_name LIKE '%" . $search . "%'";
              }
     else if($catLocation == "surname"){
                  $query .=  "surname LIKE '%" . $search . "%'";
              }
     else if($catLocation == "address"){
                  $query .=  "address LIKE '%" . $search . "%'";
              }
     else if($catLocation == "phonenumber"){
                  $query .=  "phonenumber LIKE '%" . $search . "%'";
              }
          }
    
    else{
              $query .= "1";            
          }
  
          $sql        = mysqli_query($query);
          //HERE AGAIN WAS AN ERROR... YOU PASSED mysql_fetch_array A STRING $query INSTEAD OF A RESOURCE: $sql
          while ($row = mysqli_fetch_array($sql)){
              $firstname  = $row["first_name"];
              $surname    = $row["surname"];
              $address   = $row["address"];
              $phonenumber = $row['phonenumber'];
              
  
              echo "First Name :  $firstname&lt;br&gt;";
              echo "Surname : $surname&lt;br&gt;";
              echo "Address : $address&lt;br&gt;";
              echo "Phone Number: $phonenumber&lt;br&gt;";
            
          }
  
      }
   
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The code doesn't provide any errors just a blank area where it should be. Also wondering if anyone know if it's possible to have first_name and surname as fields and search say "Emma Watson" and to be able to return results from both fields if one of the words are in there? </p>
  
  <p>Thanks for all your help!</p>