<?php

    $request_json=$_REQUEST["data"];
    $arr = json_decode($request_json, true);
    $doc_id = $arr["doc_id"];
    //include 'common/connection.php';
    $servername = "localhost";
    $username = "finstech_sales";
    $password = "SalesApp@123";
    $dbname = "finstech_salesapp";
    
    
    try {
        $pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
        $qry = "select data_b64 from master_documents where doc_id=?";
        $stmt = $pdo->prepare($qry);
        $stmt->execute([$doc_id]); 
        $user = $stmt->fetch();
        
        $jsontext = "{";
        foreach($user as $key => $value) {
            $jsontext .= "\"".addslashes($key)."\":\"".addslashes($value)."\",";
        }
        $jsontext = substr_replace($jsontext, '', -1); // to get rid of extra comma
        $jsontext .= "}";
        
        echo $jsontext;
    }catch(PDOException $e) {
        echo $sql . "err" . $e->getMessage();
    }
    $pdo = null;
    
?>