<?php
session_start();

header('Content-Type: application/json');
include 'conn.php';

$sql = "SELECT * FROM products ORDER BY id DESC";
$result = mysqli_query($con, $sql);

$products = [];
while ($row = mysqli_fetch_assoc($result)) {
    $products[] = $row;
}

if (!$result) {
    echo json_encode([
        'status' => 'error',
        'message' => mysqli_error($con)
    ]);
    exit;
}
?>
