<?php

require 'conexion.php';

$categoryData = array();
$categoryNames = array();

$categoryQuery = "SELECT category_id, category_name, category_image FROM categories";

$stmt = $connect->prepare($categoryQuery);
$stmt->execute();
$categoryResult = $stmt->get_result();

if ($categoryResult && $categoryResult->num_rows > 0) {
    while ($row = $categoryResult->fetch_assoc()) {
        $imageData = base64_encode($row['category_image']);
        $imageType = 'image/png';
        $categoryNames[$row['category_name'] . ' ' . $row['category_id']] = "data:$imageType;base64,$imageData";
    }
}

echo json_encode($categoryNames);
