<?php
include 'libs/database.php';

$obj = new Database();

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

    $category_id = $_POST['category_id'];

    $obj->sql("SELECT * FROM sub_category 
    WHERE category='$category_id' 
    ORDER BY id ASC");

    $result = $obj->getResult();

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

    foreach($result as $row){
        echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
    }
}
?>