isLoggedIn()) { throw new Exception('Unauthorized'); } $attributeId = isset($_GET['attribute_id']) ? (int)$_GET['attribute_id'] : 0; if (!$attributeId) { throw new Exception('Attribute ID is required'); } $db = Database::getInstance(); $stmt = $db->prepare("SELECT name, choices FROM attributes WHERE id = ?"); $stmt->bind_param('i', $attributeId); $stmt->execute(); $result = $stmt->get_result(); if (!$result || $result->num_rows === 0) { throw new Exception('Attribute not found'); } $attribute = $result->fetch_assoc(); $choices = json_decode($attribute['choices'], true); echo json_encode([ 'success' => true, 'attribute_name' => $attribute['name'], 'choices' => $choices ]); } catch (Exception $e) { echo json_encode([ 'success' => false, 'message' => $e->getMessage() ]); }