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

$sub_id = $_POST['sub_category_id'] ?? 0;

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

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

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