<?php 
// Include the database config file 
include_once 'connection.php'; 

 
if(!empty($_POST["subject_id"])){ 
    // Fetch state data based on the specific country 
    
    $query_1= mysqli_query($conn,"SELECT * FROM subject_soes WHERE status = 1 AND subject_id = ".$_POST['course_code']."")or die(mysqli_error());
    $class1 = mysqli_fetch_array($query_1);
    $course_code=$class1['course_code'];
    $query = "SELECT * FROM module_soes WHERE status = 1 AND subject_id = ".$_POST['subject_id']."  ORDER BY code ASC"; 
    $result = $conn->query($query); 
     
    // Generate HTML of state options list 
    if($result->num_rows > 0){ 
        echo '<option value="">Select Module</option>'; 
        while($row = $result->fetch_assoc()){  
            echo '<option value="'.$row['module_id'].'">'.$row['course_code'].' |'.$row['code'].'</option>'; 
        } 
    }else{ 
        echo '<option value="">Module not available</option>'; 
    } 
}elseif(!empty($_POST["module_id"])){ 
    // Fetch city data based on the specific state 
    $query = "SELECT * FROM cities WHERE state_id = ".$_POST['state_id']." AND status = 1 ORDER BY city_name ASC"; 
    $result = $conn->query($query); 
     
    // Generate HTML of city options list 
    if($result->num_rows > 0){ 
        echo '<option value="">Select city</option>'; 
        while($row = $result->fetch_assoc()){  
            echo '<option value="'.$row['city_id'].'">'.$row['city_name'].'</option>'; 
        } 
    }else{ 
        echo '<option value="">City not available</option>'; 
    } 
} 
?>
<script src="../stp_con/jquery/jquery.min.js"></script> 
 