<?php
require_once("../config/database.php");

$databaseService = new DatabaseService();
$con = $databaseService->getConnection();

if(isset($_POST["menu_id"])){
    //Get all state data
    $menu_id= $_POST['menu_id'];
    $query = "SELECT * FROM submenu WHERE submenu_menu_id = '$submenu_menu_id'  && submenu_status='1'";
    $run_query = mysqli_query($con, $query);
    
    //Count total number of rows
    $count = mysqli_num_rows($run_query);
    
    //Display states list
    if($count > 0){
        echo '<option value="">Select Sub Category</option>';
        while($row = mysqli_fetch_array($run_query)){
        $submenu_menu_id=$row['submenu_menu_id'];
        $submenu_name=$row['submenu_name'];
        echo "<option value='$submenu_menu_id'>$submenu_name</option>";
        }
    }else{
        echo '<option value="">Sub Menu not available</option>';
    }

}

?>