<?php
//include "application/scripts/connect.php";


function get_comment($session,$exam_id,$student_id){
include "application/config/database.php";

$hostname = $db['default']['hostname'];
$username = $db['default']['username'];
$password = $db['default']['password'];
$database = $db['default']['database'];
$dbdriver = $db['default']['dbdriver'];


// Create connection
$conn_db = mysqli_connect($hostname, $username, $password, $database);
// Check connection
if (!$conn_db) {
    die("Connection failed: " . mysqli_connect_error());
}
	$sql2 = "SELECT * from `exam_results_comment` WHERE session='$session' AND exam_id='$exam_id' AND student_id='$student_id' ORDER BY `id` DESC LIMIT 1;";
	$query2 = mysqli_query($conn_db, $sql2);
		if(mysqli_num_rows($query2) == 0){
		$sql3 = "INSERT INTO `exam_results_comment` (`session`, `exam_id`, `student_id`) VALUES ('$session', '$exam_id', '$student_id');";
		$query3 = mysqli_query($conn_db, $sql3);
		return "";
		}
		else {
			$row = mysqli_fetch_assoc($query2);
			$comment = array();
			$comment['teacher_comment'] = $row['teacher_comment'];
			$comment['head_comment'] = $row['head_comment'];
			return $comment;
		}

}

/*

function get_comment($session,$exam_id,$student_id){
			$comment = array();
			$comment['teacher_comment'] = "comment";
			$comment['head_comment'] = "comment";
			return $comment;
		

}

*/

?>  