title: Multiple Dropdowns Dynamic Query AJAX PHP MySQL
body: <p>I am currently creating a multiple dropdown query where the user can query by (3) factors for returning results, my issue is how can I do this in an efficient manner so I am not obscurely writing multiple possible MySQL Queries.</p>
  
  <pre><code>&lt;select name="class"&gt; 
  &lt;OPTION VALUE='any'&gt;Choose Class
  &lt;option value="a"&gt;Block A&lt;/option&gt;
  &lt;option value="b"&gt;Block B&lt;/option&gt;
  &lt;option value="c"&gt;Block C&lt;/option&gt;
  &lt;/select&gt;
  
   &lt;select name="category"&gt; 
   &lt;OPTION VALUE='any'&gt;Choose Type
   &lt;option value="math"&gt;Math&lt;/option&gt;
   &lt;option value="science"&gt;Science&lt;/option&gt;
   &lt;option value="history"&gt;History&lt;/option&gt;
   &lt;/select&gt;
  </code></pre>
  
  <p>How can I successfully create a MySQL query that will correctly select the right parameters in the case that a variable is missing. In example, if they choose to do the first dropdown and only search for the "class" and not choose the second dropdown. I want to be able to do the first query, the second query or both of them. I have the PHP, Ajax written, I'm just stumped as to the correct structure of the MySQL query.</p>