<?php require_once("includes/initialize.php");
global $database;
/*$id=$session->user_id;
$biodata = Biodata::find_by_id($session->user_id);
$session_class = SESSIONCLASS::session_authenticate();
$dp = DEPARTMENTCLASS::department_authenticate($biodata->courses);
$display_course = COURSECLASS::fetch_all_course($biodata->courses, $biodata->programme, $session_class->semester);

echo $dept = $biodata->courses;
echo $level = $biodata->programme;
echo $semester =$session_class->semester;*/

if (isset($_GET['semester'])) {
    $dept = $_GET['department'];
    $level = $_GET['level'];
    $semester = $_GET['semester'];
    echo $dept . ' ' . $level . ' ' . $semester;
    $query = "
				SELECT course_code, course_title, course_unit FROM tbl_courses 
				WHERE department = '$dept' AND  level = '$level' AND semester = '$semester'
				";
    //$statement = $connect->prepare($query);
    $result = $database->query($query);
    echo '<thead>
			                <tr>
			                    <th>Course Code</th>  
			                    <th>Course Tittle</th>  
			                    <th>Course Unit</th>
								<th>Select</th>								
			                </tr>
			        	</thead>';

    /*$statement->execute(
        array(
            ':department'		=>	$_POST["query"],
            ':level'		=>	$_POST["query"],
            ':semester'		=>	$_POST["query"]
        )
    );*/
    //$result = $statement->fetchAll();
    //echo '<table border="1px solid black; ">';
    foreach ($result as $r) {
        echo '<tr>'
            . '<td>' . $r['course_code'] . '</td>'
            . '<td>' . $r['course_title'] . '</td>'
            . '<td>' . $r['course_unit'] . '</td>'
            . '<td><input type="checkbox" name="check-tab1"></td>'
            . '</tr>';
    }
    //echo '</table>';
} else {
    echo 'No POST';
}

?>