<?php
header('Content-Type: application/json');
include_once('../includes/config.php');

if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    echo json_encode([
        'success' => false,
        'message' => 'Invalid customer ID'
    ]);
    exit;
}

$customerId = (int)$_GET['id'];

$query = "SELECT * FROM tblcustomers WHERE ID = $customerId";
$result = mysqli_query($con, $query);

if ($result && mysqli_num_rows($result) > 0) {
    $customer = mysqli_fetch_assoc($result);
    echo json_encode([
        'success' => true,
        'customer' => $customer
    ]);
} else {
    echo json_encode([
        'success' => false,
        'message' => 'Customer not found'
    ]);
}
?>
