title: Possible to have PHP MYSQL query ignore empty variable in WHERE clause?
body: <p>Not sure how I can do this.  Basically I have variables that are populated with a combobox and then passed on to form the filters for a MQSQL query via the where clause.  What I need to do is allow the combo box to be left empty by the user and then have that variable ignored in the where clause.  Is this possible?</p>
  
  <p>i.e., from this code.  Assume that the combobox that populates $value1 is left empty, is there any way to have this ignored and only the 2nd filter applied.</p>
  
  <pre><code>$query = "SELECT * FROM moth_sightings WHERE user_id = '$username' AND location = '$value1' AND english_name = $value2 ";
  $result = mysql_query($query) or die(mysql_error());
  $r = mysql_numrows($result);
  </code></pre>
  
  <p>Thanks for any help.
  C</p>