Greetings!

I have want to have a search query that will based on user preference.

PHP Code:
$avail $_POST['avail'];
$sec $_POST['section'];

$query "SELECT * ,b.b_Title as title, bac.id as bacid FROM tbl_book AS b
                      LEFT JOIN tbl_bdetail AS bd ON b.id = bd.b_Title
                      LEFT JOIN tbl_bacquisition AS bac ON bac.bd_Id = bd.id"
;

    if (
count($avail)>0)
    {
$query.="WHERE bac.ba_Status = '$avail'";}
        if (
count($sec)>0)
    {
$query.="WHERE b.section_Id = '$sec'";    } 
What I am trying here is that when the user select the $sec option, I want to add the WHERE clause value in my $query, when the user select the $avail option I want to add the WHERE clause values.

My problem is what if the user will select values among the two options? how can I make it happen. any help will do.