<?php
//Include database configuration file
include('../Server/connection.php');

if(!empty($_POST["depart_id"])){ 
    // Fetch state data based on the specific country 
    $query = "SELECT * FROM sections WHERE dept_id = ".$_POST['depart_id']." ORDER BY sect_name ASC"; 
    $result = $conn->query($query); 
     
    // Generate HTML of state options list 
    if($result->num_rows > 0){ 
        echo '<option value="">Select Section</option>'; 
        while($row = $result->fetch_assoc()){  
            echo '<option value="'.$row['sect_id'].'">'.$row['sect_name'].'</option>'; 
        } 
    }else{ 
        echo '<option value="">Section not available</option>'; 
    } 
}elseif(!empty($_POST["section_id"])){ 
    // Fetch city data based on the specific state 
    $query = "SELECT * FROM designation WHERE sect_id = ".$_POST['section_id']." and staffcate_id=2 ORDER BY des_name ASC"; 
    $result = $conn->query($query); 
     
    // Generate HTML of city options list 
    if($result->num_rows > 0){ 
        echo '<option value="">Select Designation</option>'; 
        while($row = $result->fetch_assoc()){  
            echo '<option value="'.$row['des_id'].'">'.$row['des_name'].'</option>'; 
        } 
    }else{ 
        echo '<option value="">Designation not available</option>'; 
    } 
}


/*
if(!empty($_POST["dept_id"])){
	
	
    //Get all state data
    $query = $conn->query("SELECT * FROM sections WHERE dept_id = ".$_POST['dept_id']." ORDER BY sect_name");
    
    //Count total number of rows
    $rowCount = $query->num_rows;
    
    //Display states list
    if($rowCount > 0){
        //echo '<option value="">Chagua Kata</option>';
        while($row = $query->fetch_assoc()){ 
            echo '<option value="'.$row['sect_id'].'">'.$row['sect_name'].'</option>';
        }
    }else{
        echo '<option value="">No Section </option>';
    }
	

			
}
*/

?>