<?php
	require_once '../../autoload.php';
	require( '../GetDataFromDB.php' );

	RightsCheck ('VIEW_WARNING');

	$id = $_POST["id"];

	$psql= "select title,description from examwarning,examwarning_link where examwarning.id = examwarning_link.examwarning_id and examwarning_link.exam_id = $id and examwarning.removed = false order by title";
	 
	$conn = get_dbconnection();

	$arr = array ();

	if ( $query = pg_query ( $conn, $psql) )
	{
		while ( $row = pg_fetch_row($query) )
		{
	        $res = array ( 
	        		"title" 		=> $row [0],
	        		"description" 	=> $row [1]
	        	);

	        array_push ( $arr, $res );
		}
	}
	
	header('Content-type: application/json');
	
	$result = json_encode ( $arr );

	echo $result;
 
?>