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

function get_exam_settings($session,$exam_id){
//define('BASEPATH', "/smartsms/");
//define('ENVIRONMENT', "production");
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_settings` WHERE session='$session' AND exam_id='$exam_id' ORDER BY `id` DESC LIMIT 1;";
	$query2 = mysqli_query($conn_db, $sql2);
		if(mysqli_num_rows($query2) == 0){
		$sql3 = "INSERT INTO `exam_settings` (`session`, `exam_id`) VALUES ('$session', '$exam_id');";
		$query3 = mysqli_query($conn_db, $sql3);
		return "";
		}
		else {
			$row = mysqli_fetch_assoc($query2);
			$exam_setting = array();
			$exam_setting['term_started'] =$row['term_started'];
			$exam_setting['term_ended'] = $row['term_ended'];
			$exam_setting['next_begin'] = $row['next_begin'];
			$exam_setting['foot_note'] = $row['foot_note'];
			return $exam_setting;
		}

}




?>  