title: php mysql function with optional parameter
body: <p>I need help with giving optional parameters for php function which will search in MySQL database for the matching criteria.</p>
  
  <p>Scenario: Front-end =
  There will be 6 html input form field named as authorName, authorCountry, authorState and so on</p>
  
  <p>When user fills this fields, field values will be passed as a mysql parameters for searching db. Here the problem is, if user wants to know the list of authors in USA, he will enter USA in country field and leave other fields. But this will break the mysql query since other fields are left blank.</p>
  
  <p>i tried doing but it dint work for me.</p>
  
  <pre><code>function getAuth(authName=NULL, authCoun=NULL, authSate=NULL) {
  $query = mysql_query("SELECT * FROM authTable WHERE authName='authName'
  AND authCoun='authCoun' AND authSate='authSate'");
  return $query; }
  </code></pre>
  
  <p>Please help me to pass optional parameter.</p>
  
  <p>Thank you..</p>