title: searching form in php with drop down menu
body: <p>Good day! I'm just a newbie in php programming so I need somebody to help me with this one. I still cannot find what's wrong with this code. I created a search form with drop down menu to filter the results. But nothing happens when I do a searching. It's either it's just refreshes the page or display error criteria message. any answer will be appreciated! :) thanks in advance! Here is the code:</p>
  
  <pre><code>   &lt;html&gt;
      &lt;head&gt;
  &lt;basefont face="Arial"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php
  error_reporting(E_ALL); 
  if (!isset($_POST['Submit'])) {
  // form not submitted
  ?&gt;
  
  &lt;form action="&lt;?=$_SERVER['PHP_SELF']?&gt;" method="post"&gt;
  search  
    &lt;input type="text" name="search"&gt;
     &lt;select size="1" name="dropdown"&gt;
      &lt;option value="" selected&gt;search By...&lt;/option&gt;
      &lt;option value="first"&gt;Company&lt;/option&gt;
      &lt;option value="last"&gt;Address&lt;/option&gt;  
    &lt;/select&gt;
    &lt;input type="Submit" value="Submit" name="Submit"&gt; 
  &lt;/form&gt;
  
  &lt;?php
  }
  
  else {
  
  // Server Variables
  $host = "localhost";
  $user = "mdti";
  $pass = "tnet";
  $db = "ojt";
  
  $search = empty($_POST['search'])? die ("ERROR: Enter search Criteria") : mysql_escape_string($_POST['search']);
  $dropdown = empty($_POST['dropdown'])? die ("ERROR: Select from dropdown") : mysql_escape_string($_POST['dropdown']);
  
  
  // Open Connection
  
  $connect = mysql_connect($host, $user, $pass) or die ("Unable to connect to host");
  
  //Select Database
  
  mysql_select_db($db) or die ("Unable to connect to database");
  
  //Create query
  
  $query = "SELECT arCompanyname, arAddress FROM ar WHERE $dropdown like'$search'" or die (mysql_error());
  
  
  $result = mysql_query($query) or die (mysql_error());
  
  $num=mysql_numrows($result);
  
  mysql_close($connect);
  
  echo "&lt;b&gt;&lt;center&gt;Database Output&lt;/center&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
  
  $i=0;
  while ($i &lt; $num) {
  
  $company=mysql_result($result,$i,"arCompanyname");
  $address=mysql_result($result,$i,"arAddress");
  
  
  echo "&lt;br&gt;Company: $company&lt;br&gt;&lt;br&gt;Address: $address&lt;hr&gt;&lt;br&gt;";
  
  $i++;
  
  }
  }
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>