<?php
require '../db.php';

if (isset($_POST['pid'])) {
    $pid = $_POST['pid'];
    $query = "SELECT * FROM product WHERE pid = $pid";
    $result = mysqli_query($con, $query);
    $rows = mysqli_fetch_assoc($result);

    ob_start();
    include 'final_document_content.php'; // Separate PHP file for modal HTML
    $html = ob_get_clean();

    echo json_encode(['html' => $html]);
}
?>