<?php
// fetch_vendors.php

header('Content-Type: application/json');
require 'shikanisha.kts.php'; // Update with your actual database connection script

$response = [];

try {
    // Fetch vendor data
    $query = "SELECT `company`, `vendor_id` FROM `vendors`";
    $result = $conn->query($query);

    if (!$result) {
        throw new Exception("Database query failed: " . $conn->error);
    }

    $vendors = [];
    while ($row = $result->fetch_assoc()) {
        $vendors[] = $row;
    }

    $response['status'] = 'success';
    $response['vendors'] = $vendors;
} catch (Exception $e) {
    $response['status'] = 'error';
    $response['message'] = $e->getMessage();
}

echo json_encode($response);
?>
