<?php
include 'db.php';
header('Content-Type: text/html');

$cat_id = $_POST['category_id'] ?? 0;

$res = mysqli_query($conn, "
    SELECT * FROM products 
    WHERE category_id='$cat_id'
    AND (subcategory_id = 0)
    AND status='active'
");

echo '<option value="">Select Product</option>';

while ($row = mysqli_fetch_assoc($res)) {
    echo "<option value='{$row['id']}'>{$row['name']}</option>";
}