<?php
header('Content-Type: application/json');

$host = "localhost";
$user = "blenco1_billing_system";
$password = "Hafshan@2552";
$dbname = "blenco1_billing_system";

$conn = new mysqli($host, $user, $password, $dbname);
if ($conn->connect_error) {
    echo json_encode([]);
    exit;
}

$sql = "SELECT id, name, type FROM customers ORDER BY name ASC";
$result = $conn->query($sql);

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

echo json_encode($clients);
?>