Multiple WHERE conditions in SQL query
<p>I have students details in my database.
<code>php
firstname
lastname
DOB
gender
status (Active, Not Active)
fee_paid
</code></p>

<p>I also have a search form on the views that I want to use to search students based on different conditions.</p>

<p>For example, I may want to search these
1. All female students who were born between date1 to date2 and have paid x amount of fees.
2. All students called Ali who have paid x amount of fees.
3. All Active students who have not paid any fees.</p>

<p>My question, how can I simply check, if a field is set, then use it in a query, otherwise don't include it in the query. Also for DOB, search is by date range.</p>