<?php
// Include your database connection code here

// Query to retrieve updated MRP data (similar to your existing query)
$mrpBaruQuery = "SELECT ...";

$mrpBaruResult = $db->query($mrpBaruQuery);

// Generate HTML for the updated MRP table
$html = '';
if ($db->num_rows($mrpBaruResult) > 0) {
    // Generate HTML for the MRP table
    $html .= '<table class="table table-bordered table-hover">';
    $html .= '<thead>';
    $html .= '<tr>';
    $html .= '<th>Part Number</th>';
    $html .= '<th>Product Name</th>';
    $html .= '<th>Total Requirement</th>';
    $html .= '<th>Calculate (Kg)</th>';
    $html .= '<th>Stock</th>';
    $html .= '</tr>';
    $html .= '</thead>';
    $html .= '<tbody>';
    
    while ($row = $db->fetch_assoc($mrpBaruResult)) {
        // Generate table rows here
        $html .= '<tr>';
        $html .= '<td>' . htmlspecialchars($row['part_number']) . '</td>';
        $html .= '<td>' . htmlspecialchars($row['product_name']) . '</td>';
        $html .= '<td>' . number_format($row['name'], 2, '.', '') . '</td>';
        $html .= '<td>' . number_format($row['calculate'], 2, '.', '') . ' Kg</td>';
        $html .= '<td>' . htmlspecialchars($row['stock']) . '</td>';
        $html .= '</tr>';
    }
    
    $html .= '</tbody>';
    $html .= '</table>';
} else {
    // If no new data, return a message saying no new data
    $html = '<p>No new MRP data available.</p>';
}

// Return the generated HTML
echo $html;
?>
