<?php
include("../db.php");

if(isset($_POST['college_id'])){
    $college_id = mysqli_real_escape_string($con, $_POST['college_id']);

    // Fetch departments from `data` table
    $dep_sql = mysqli_query($con, "SELECT data_title, data_short_des FROM data WHERE data_catagory = 'Department' AND data_up_for = '$college_id' AND data_recycle = '1'");

    echo '<option value="">Select From List</option>';
    while($dep_row = mysqli_fetch_assoc($dep_sql)){
        $dept_sql = mysqli_query($con, "SELECT * FROM  clg_course_cat WHERE sl_no = '$dep_row[data_short_des]'");
        if($dept_row = mysqli_fetch_assoc($dept_sql)){
            $dept_name = $dept_row["cat_name"];
        }
        echo '<option value="'.$dep_row['data_short_des'].'">'.$dept_name.'</option>';
    }
}
?>