<?php
include("dbConfig.php");
// Check if patientId is sent via POST
if (isset($_POST['patientId'])) {
    $patientId = $db->real_escape_string($_POST['patientId']);

    // SQL query to get PayableAmount for the given PatientId
    $sql = "SELECT PayableAmount FROM bill WHERE PatientId = '$patientId' LIMIT 1";
    $result = $db->query($sql);

    if ($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        // Output the PayableAmount
        echo $row['PayableAmount'];
    } else {
        // If no record found, return a default message
        echo "No record found";
    }
} else {
    echo "Invalid Request";
}

// Close the connection
$db->close();
?>
