Search Results

Search found 1 results on 1 pages for 'user3661845'.

Page 1/1 | 1 

  • Query building depending checkboxes selection

    - by user3661845
    I want to build a query form my database depending my checkboxes list. My checkboxes: <input type="checkbox" id="searchName" checked> Name <input type="checkbox" id="searchAddress"> Address <input type="checkbox" id="searchCompany"> Company <input type="checkbox" id="searchComments"> Comments My PHP: $subQuery=''; if($_POST['searchName']=='true') { $subQuery .= " AND KDX_Name LIKE :KDX_SearchTerm"; } if($_POST['searchAddress']=='true') { $subQuery .= " OR KDX_PostalAddress LIKE :KDX_SearchTerm"; } if($_POST['searchCompany']=='true') { $subQuery .= " OR KDX_Company LIKE :KDX_SearchTerm"; } if($_POST['searchComments']=='true') { $subQuery .= " OR KDX_Comments LIKE :KDX_SearchTerm"; } My problem: If the first checkbox is not checked, my query is not working cause it works with OR whereas it must start with AND. Could you please help ? Thanks.

    Read the article

1