The below code displays data from a table and then filters it depending on the results of two combo boxes. I am able to order the results by ID once the form is submitted, but not on initial load (where all are listed). I have tried $sql = "SELECT * FROM Places ORDER BY ID"; which works when the list loads but returns an error when the form is submitted. Hope that makes sense. Any ideas? Thanks!
// Default query
$sql = "SELECT * FROM Places";
// check if form was submitted
if (isset($_POST['area'])) {
    $connector = 'where';
    if ($_POST['area'] != 'All') { 
        $sql .= " where Area = '".$_POST['area']."' ORDER BY ID";
        $connector = 'and';
    }
    if ($_POST['theme'] != 'All') { 
        $sql .= " $connector Theme = '".$_POST['theme']."' OR Theme2 = '".$_POST['theme']."' 
        ORDER BY ID";
    }
}
 
     
     
    