setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("Database connection failed: " . $e->getMessage()); } // Handle Payment Status Update if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["emiId"]) && isset($_POST["status"])) { $emiId = $_POST["emiId"]; $status = $_POST["status"]; try { $stmt = $db->prepare("UPDATE billing SET emi".$emiId."Status = :status WHERE customerId = :customerId"); $stmt->bindParam(':status', $status, PDO::PARAM_INT); $stmt->bindParam(':customerId', $_POST["customerId"]); $stmt->execute(); echo json_encode(["success" => true, "message" => "Payment status updated"]); } catch (PDOException $e) { echo json_encode(["success" => false, "message" => "Error updating payment status"]); } exit; } // Fetch Customer Billing Data if (!isset($_GET['customerId'])) { die("Invalid request: Customer ID is required."); } $customerId = $_GET['customerId']; $stmt = $db->prepare("SELECT * FROM billing WHERE customerId = :customerId"); $stmt->bindParam(':customerId', $customerId); $stmt->execute(); $billingData = $stmt->fetch(PDO::FETCH_ASSOC); if (!$billingData) { die("No billing data found for this customer."); } ?>

Customer Billing Details

"; } ?>
# EMI Date Amount Status Action
{$i} {$emiDate} ₹{$emiAmount} " . ($emiStatus == 1 ? "Paid" : "Unpaid") . "