<?php
// fetch_customers.php

// Database connection
require_once 'shikanisha.kts.php';

// Fetch data from the customers table
$query = "SELECT `customer_id`, `full_name`, `country`, `county`, `location`, `phone_number` FROM `customers`";
$result = mysqli_query($conn, $query);

// Check for errors
if (!$result) {
    die(json_encode(['error' => 'Database query failed.']));
}

// Fetch data as an associative array
$data = [];
while ($row = mysqli_fetch_assoc($result)) {
    $data[] = $row;
}

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

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