<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");
include '../connection.php';

$sql = "SELECT id, name, icon FROM tbl_service_type ORDER BY id DESC";
$result = $conn->query($sql);

$productTypes = array();

if ($result && $result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $productTypes[] = $row;
    }
    echo json_encode(["success" => true, "data" => $productTypes]);
} else {
    echo json_encode(["success" => false, "message" => "No product types found"]);
}

$conn->close();
?>