<?php
include($_SERVER['DOCUMENT_ROOT'] . "/API-Others/connection/conn.php");
header('content-type:application/json');
$query = mysqli_query($conn, "SELECT * FROM config_types");
$config_types = array();
while ($spec = mysqli_fetch_assoc($query)) {
    $configs = array();
    $product_array_query = mysqli_query($conn, "SELECT  id, config_type_id, name FROM config WHERE config_type_id = '" . $spec['id'] . "'");
    while ($product_array_fetch = mysqli_fetch_array($product_array_query)) {
        $configs[] = $product_array_fetch['name'];
    }
    $config_types[$spec['config_type']] =  $configs;
}

$resultData = array('code' => $statusCode, 'message' => $statusMessage, 'data' => $config_types);
echo json_encode($resultData);
