query($sql); $contacts = $data->fetchAll(PDO::FETCH_ASSOC); $json = json_encode($contacts, JSON_PRETTY_PRINT); print($json);