setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch customer data
$stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId ORDER BY regDate DESC");
$stmt->bindParam(':customerId', $customerId);
$stmt->execute();
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch invoice data
$stmt2 = $db->prepare("SELECT * FROM invoice");
$stmt2->execute();
$invoiceContent = $stmt2->fetchAll(PDO::FETCH_ASSOC);
// Loop through each customer
$customerSerial = 1;
foreach ($content as $customer) {
// Find all invoices for the current customer
$matchingInvoices = array_filter($invoiceContent, function ($invoice) use ($customer) {
return $invoice['customerId'] === $customer['customerId'];
});
// If there are matching invoices, loop through them
if (!empty($matchingInvoices)) {
foreach ($matchingInvoices as $invoice) {
?>
|
|
|
|
|
|
|
EMI Details
Print
|
|
|
|
|
No invoice available |
EMI Details
|
Error: ' . $e->getMessage() . ' | ';
}
?>