<?php 
include 'config-result.php';

if (isset($_POST['className'])) {
    $className= $_POST['className'];
    $className = mysqli_real_escape_string($link, $className);
	$query = "SELECT distinct(a.group_id) as group_id,
    b.st_group as st_group
    FROM 
    class_routine a
    LEFT JOIN
    group_name b
    on a.group_id=b.group_id 
    where a.class_id= '$className' order by group_id";
    
  /*   $query = "SELECT distinct(a.st_group) as stt_group,b.group_id as group_id
    FROM class_routine a
    INNER JOIN group_name b
    ON a.st_group = b.st_group  
    where a.class_id= '$classNam' order by group_id";

 */
        $result = mysqli_query($link, $query);
        // $row = mysqli_fetch_assoc($result);
        // echo $row['stt_group']; 
    $numRows = mysqli_num_rows($result);
    if ($numRows > 0 ) {
			echo '<option value="">--Select Group--</option>';
            while($row = mysqli_fetch_assoc($result)){
		 	echo '<option value='.$row['group_id'].'>'.$row['st_group'].'</option>';
		 }
	}else{

		echo '<option>Not Found!</option>';
	}

	

}


?>
