title: PHP advanced search with Multiple OPTION
body: <p>I am building a search field with php where users can search for Doctors information with multiple search options.
  <a href="https://i.stack.imgur.com/nTLDX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nTLDX.png" alt="SEARCH"></a></p>
  
  <p>As shown in the picture a user can search by: DR.NAME, SPECIALTY, DIVISION, LOCATION. The DR.NAME should match any keyword and the form doesn't require any fields to be filled out.</p>
  
  <p>This is my current code which isn't working.</p>
  
  <p>doctorsearch.php</p>
  
  <pre><code>&lt;?php
      error_reporting(0);
  
      include 'config.php';
  
      $d_fname = $_POST['d_fname'];
      $d_spcl = $_POST['d_spcl'];
      $d_division = $_POST['d_division'];
      $d_location = $_POST['d_location'];
  
  
      $qry = "SELECT * FROM doctor_reg WHERE ";
      if ($d_fname != '') {
          $qry .= "d_fname='".mysql_real_escape_string($d_fname)."' AND ";
      }
      if ($d_spcl != '') {
          $qry .= "d_spcl='".mysql_real_escape_string($d_spcl)."' AND ";
      }
      if ($d_division != '') {
          $qry .= "d_division='".mysql_real_escape_string($d_division)."' AND ";
      }
      if ($d_location != '') {
          $qry .= "d_location='".mysql_real_escape_string($d_location)."' AND ";
      }
  
      $result = mysql_query($result);
  
          ?&gt;  
  
              &lt;?php
              echo "&lt;table border='1px solid #CCCCCC;' width='100%'&gt;";
              echo "&lt;tr style='color:#FFFFFF;background:#555555;'&gt;";
              echo "&lt;th style='padding:3px;'&gt;Name&lt;/th&gt;";
  
  
              while($row = mysql_fetch_array($result)){
                  echo "&lt;tr class='trbd'&gt;";
              echo "&lt;td style='padding:3px;'&gt;".$row['d_fname'].' '.$row['d_lname']."&lt;/td&gt;";
  
              ?&gt;
  
              &lt;?php
              echo "&lt;/tr&gt;";
  
      }
              echo "&lt;/table&gt;";
      ?&gt;
  </code></pre>