<?php
ob_start();
require 'config.php';
ob_clean();
header('Content-Type: application/json');

$stmt = $pdo->query("SELECT id, name, price, category, img FROM products WHERE is_active = 1 ORDER BY category, name");
echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));