<?php
// Your existing PHP code for fetching data goes here
include_once('shikanisha.kts.php');

// Instead of echoing HTML, build an array and encode it as JSON
$data = array();
while ($row = mysqli_fetch_assoc($result)) {
    $data[] = array(
        'Name' => $row['vendor_name'],
        'Amount Owed' => $row['amount_owned'],
        'Action' => '<button type="button" class="btn btn-primary paymentBtn" data-toggle="modal" data-target="#paymentModal" data-vendor-id="'.$row['vendor_id'].'">Manage Payments</button>'
    );
}

// Output the JSON data
header('Content-Type: application/json');
echo json_encode($data);
?>
