<?php
// Include your database connection code
require_once 'shikanisha.kts.php';

// Fetch vendor data from the database
$sql = "SELECT vendors.*, vendor_debts.id AS debt_id, vendor_debts.amount_owed AS amount_owed
        FROM vendors
        LEFT JOIN vendor_debts ON vendors.vendor_id = vendor_debts.vendor_id";
$result = mysqli_query($conn, $sql);

// Fetch data and store it in an array
$vendors = [];
while ($row = mysqli_fetch_assoc($result)) {
    $vendors[] = $row;
}

// Close the database connection
mysqli_close($conn);

// Return vendor data as JSON
echo json_encode($vendors);
?>
