title: Drop Down Menu - populated from a mysql database
body: <p>I have 3 table in a database and I would like to populate two dropdown menu with  value from 'brands and categories' table, so that a user can select categories and brands and then a search or a display page would be produced on the basis of their selections from products table</p>
  
  <p>I am fairly new to php, but have a MySQL database to which I can add/edit/del and produce results from, but am unsure how to do the above..</p>
  
  <p>I have 3 tables</p>
  
  <ol>
  <li><p>brands:</p>
  
  <pre><code> brand_id
   brand_title
  </code></pre></li>
  <li><p>categories:</p>
  
  <pre><code>cat_id
  cat_title
  </code></pre></li>
  <li><p>products:</p>
  
  <pre><code>product_id
  product_cat
  product_brand
  product_price
  product_keywords
  </code></pre></li>
  </ol>
  
  <p>my php code here: 
  This code fetch data from brands and categories table in 2 dropdown.
  now i want to search by keywords and display data from product table by what options selected from brands and categories table.
  please take a look this link:
  <a href="http://ruqayyahfashion.com/product/1.php" rel="nofollow">http://ruqayyahfashion.com/product/1.php</a></p>
  
  <pre><code>&lt;?Php
  
  mysql_connect("localhost", "root", "") or die("Connection Failed");
  mysql_select_db("ecomerce")or die("Connection Failed");
  
  
  $sql="SELECT cat_id, cat_title FROM categories"; 
  $result=mysql_query($sql); 
  
  $options=""; 
  
  while ($row=mysql_fetch_array($result))
  
  { 
  $cat_id=$row["cat_id"]; 
  $cat_title=$row["cat_title"]; 
  $options.="&lt;OPTION VALUE=\"$cat_id\"&gt;".$cat_title; 
  } 
  
  
  $sql1="SELECT brand_id, brand_title FROM brands"; 
  $result1=mysql_query($sql1); 
  
  $options1=""; 
  
  while ($row1=mysql_fetch_array($result1))
  
  { 
  $brand_id=$row1["brand_id"]; 
  $brand_title=$row1["brand_title"]; 
  $options1.="&lt;OPTION VALUE=\"$brand_id\"&gt;".$brand_title; 
  } 
  
  
  ?&gt; 
  
  &lt;form &gt;
  &lt;input type="text" class="form-control" placeholder="Search a Product"&gt;
  &lt;SELECT NAME=Categories&gt; 
  &lt;OPTION VALUE=0&gt;Select a Category 
  &lt;?=$options?&gt; 
  &lt;/SELECT&gt; 
  
  &lt;SELECT NAME=Brands&gt; 
  &lt;OPTION VALUE=0&gt;Select a Brand 
  &lt;?=$options1?&gt; 
  &lt;/SELECT&gt; 
  
  &lt;button type="submit" name="btn"&gt;Search&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>