$sql = " SELECT * FROM user_accounts ";

        $stmt = $dbcon->pdo->prepare($sql);

         $stmt->execute();
        $data = array();

        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $data['alldata'][]= $row;
        }

echo json_encode($data);