<?php
include('../config/config.php');

if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    $stmt = $conn->prepare("SELECT id,customer_code, customer_name, address, city, pincode, contact_person, phone FROM customers WHERE id = ?");
    $stmt->bind_param("i", $id);
    $stmt->execute();
    $result = $stmt->get_result();
    $customer = $result->fetch_assoc();

    if ($customer) {
        echo json_encode($customer);
    } else {
        echo json_encode(['error' => 'No data found']);
    }
    $stmt->close();
}
?>
