<?php
include('includes/dbconn.php'); // Include your database connection script

if (isset($_POST['invoice_id'])) {
    $invoice_id = $_POST['invoice_id'];

    $query = "SELECT total_amount FROM invoices WHERE invoice_id = $invoice_id";
    $result = mysqli_query($conn, $query);

    if ($result && mysqli_num_rows($result) > 0) {
        $row = mysqli_fetch_assoc($result);
        $total_amount = $row['total_amount'];
        echo $total_amount;
    } else {
        echo "0"; // Return 0 if no total_amount is found
    }
} else {
    echo "0"; // Return 0 if invoice_id is not set
}

mysqli_close($conn);
?>
