title: Filtering My sql through Php using drop down menu and text field
body: <p>I have a little problem in php.
  problem is that i want to search MySQL table by php coding.
  In php i want to use Drop down menu And a text field.
  I have two MySQL table name is category and products, now i use category entries
  in drop-down menu (by cat_name).and in the search text area
  i want write any product name selecting by cat_name from drop down menu and then click on search button. Then it will show me the result from product table in table format.</p>
  
  <p>Can any one help me
  Thanks.
   i have tow category: Mobile and Laptop in categories table and
   i have many products name: Dell, Hp, Toshiba, Samsung, Iphone etc...in products table</p>
  
  <h2>1. categories</h2>
  
  <p>cat_id<br>
  cat_name</p>
  
  <h2>2. products</h2>
  
  <pre><code>product_id 
  product_cat 
  product_name 
  product_price
  </code></pre>
  
  <p>I have php code. this working correct till populate cat_name from database in drop-down.</p>
  
  <p>result.php</p>
  
  <pre><code> &lt;?php 
  mysql_connect ("localhost", "root","")  or die (mysql_error());
  mysql_select_db ("ecomerce");
  
  
  
  $sql = mysql_query('SELECT cat_name FROM  categories ORDER BY cat_name');
  $models = array();
  while ($row = mysql_fetch_array($sql)){
      $models[] = $row;
  }
  ?&gt;
  &lt;form action="search.php" method="post"&gt;
    &lt;select name="term"&gt;
    &lt;?php
    foreach ($models as $model) {
    ?&gt;
      &lt;option value="&lt;?php echo $model['cat_name']?&gt;"&gt;&lt;?php echo $model['cat_name']?&gt;&lt;/option&gt;
    &lt;?php
    }
    ?&gt;
    &lt;/select&gt;
  
  &lt;form &gt;
  &lt;input type="text" class="form-control" placeholder="Search a Product"&gt;
  &lt;input type="submit" name="submit" value="Search" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>search.php</p>
  
  <pre><code>&lt;?php
  
  mysql_connect ("localhost", "root","")  or die (mysql_error());
  mysql_select_db ("ecomerce");
  
  
  if(isset($_POST['term']) {
      $term = $_POST['term'];
      $query = "SELECT * FROM products WHERE product_cat = '".mysql_escape_string($term)."'";
      $result = mysql_query($query);
      while($row = mysql_fetch_assoc($result) {
          // display results
  
      echo 'Product ID '.$row['product_id'];
      echo 'product_title: '.$row['product_name'];
      echo 'product_price: '.$row['product_price'];
  
  
      }
  }
  
  ?&gt;
  </code></pre>