Filter search based on selected drop downs in PHP
<p>I have a Search form to search products.</p>

<pre><code>&lt;form method="get" action="search.php"&gt;
&lt;select name="minprice"&gt;
  &lt;option value=""&gt;Min price&lt;/option&gt;
  &lt;option value="100"&gt;100&lt;/option&gt;
  &lt;option value="200"&gt;200&lt;/option&gt;
  &lt;option value="300"&gt;300&lt;/option&gt;
  &lt;option value="400"&gt;400&lt;/option&gt;
  &lt;option value="500"&gt;500&lt;/option&gt;
&lt;/select&gt;
  &lt;select name="maxprice"&gt;
  &lt;option value=""&gt;Max price&lt;/option&gt;
  &lt;option value="100"&gt;100&lt;/option&gt;
  &lt;option value="200"&gt;200&lt;/option&gt;
  &lt;option value="300"&gt;300&lt;/option&gt;
  &lt;option value="400"&gt;400&lt;/option&gt;
  &lt;option value="500"&gt;500&lt;/option&gt;
&lt;/select&gt;
&lt;select name="type"&gt;
  &lt;option value=""&gt;type&lt;/option&gt;
  &lt;option value="electric"&gt;electric&lt;/option&gt;
  &lt;option value="other"&gt;other&lt;/option&gt;
&lt;/select&gt;
 &lt;select name="brand"&gt;
  &lt;option value=""&gt;type&lt;/option&gt;
  &lt;option value="asus"&gt;ASUS&lt;/option&gt;
  &lt;option value="ms"&gt;MS&lt;/option&gt;
  &lt;option value="other"&gt;other&lt;/option&gt;
&lt;/select&gt;
 &lt;input type="submit" name="search" value="search"&gt;
 &lt;/form&gt;
</code></pre>

<p>In <code>search.php</code> page, i need results based only on what selected.</p>

<p>If i selected single list, i need that result only.</p>

<p>Example : I selected <code>min price</code>=100 , then i need to select products with minimum price 100 only...</p>

<p>I have tried <a href="https://stackoverflow.com/questions/28817916/filtering-results-based-on-dropdown-paramenters-using-php-mysql">this</a> method , but it is not easy in my case, i am sure there is another way to implement this.</p>

<p>Any experts??</p>

<p>Any help / Ideas greatly appreciated..</p>

<p><strong>EDIT</strong></p>

<pre><code>if(isset($_GET['minprice'])
 {
   $minprice=$_GET['minprice'];
  $query="SELECT * FROM products WHERE price&gt;='$minprice'";
  }
  else if()....
   {   }
</code></pre>

<p>I am currently doing this way, But on next conditions not taking...</p>

<p>My Questions: </p>

<ol>
<li>Do only this way to get the results?</li>
<li>Any change needed on <code>$_GET['']</code> method like <code>!=""</code> or <code>empty()</code>.</li>
</ol>