header('Content-Type: application/json'); //This was commented out because View.php sends html, not json, and it was causing problems. require_once 'view.php'; require_once 'store.php'; switch ($_POST['category']) { case 'query': $array1 = $_POST['array1']; $date_from = $_POST['date_from']; $date_to = $_POST['date_to']; $submitted_filters = json_decode($array1); //use the TRUE parameter to convert to an array, not a json object, but for now we'll use an object. $test_query = new Query(); $test_query->filters = $submitted_filters; $test_query->start_date_from = $date_from; $test_query->start_date_to = $date_to; $records = $test_query->getData(); echo json_encode($records); //$view = new View($records); //$view->sendRecords(); break; case 'filters': $item = $_POST['item']; switch ($_POST['type']) { case 'Conditions': $conn = Connection::getConn(); $sql = "SELECT condition_name FROM Conditions WHERE condition_name LIKE :search_string"; $stmt = $conn->prepare($sql); try { $stmt->execute(array(':search_string' => $item . '%')); $rows = $stmt->fetchAll(PDO::FETCH_COLUMN, 0); $conn = null;