<?php
require_once "../../includes/db.php";
header('Content-Type: application/json');

$comp_id = isset($_GET['comp_id']) ? (int)$_GET['comp_id'] : 0;

$stmt = $pdo->prepare("
    SELECT id, p_name
    FROM products
    WHERE status = 'active'
    AND co_id = :comp_id
    ORDER BY id ASC
");

$stmt->execute(['comp_id' => $comp_id]);

echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));