<?php
include 'includes/connect.php';

if(isset($_POST['variety_id'])){

    $variety_id = intval($_POST['variety_id']);

    $query = "SELECT id, brand 
              FROM brand 
              WHERE variety_id = '$variety_id' 
              AND status = 'Active'
              ORDER BY brand ASC";

    $result = mysqli_query($conn, $query);

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

    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_assoc($result)){
            echo '<option value="'.$row['brand'].'">'.$row['brand'].'</option>';
        }
    } else {
        echo '<option value="">No Brand Found</option>';
    }
}
?>