
<?php
session_start();
$ansid = $_GET["r"];
		$answers = json_decode( file_get_contents( 'data/answers.json' ), true );

if ( $_GET["c"] == "up" ) {
		$answers[$ansid]["up"] += 1;
		file_put_contents( 'data/answers.json', json_encode( $answers));
}
if ( $_GET["c"] == "down" ) {
		$answers[$ansid]["down"] += 1;
		file_put_contents( 'data/answers.json', json_encode( $answers));
}
?>
<html>
<head>
<title> The Learning Jar </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<meta content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name = "viewport" />
</head>
<body>
<div id=container>
	<div id=top-logo>
	<center>
	<img src=img/mypage_s.png>
	<a href=index.php>
	<img src=img/logo_s.png width=250>
	</a>
	</center>
	</div>

	<div id=content>
	<?php
		$qid = $answers[$ansid]["qid"];
		$author = $answers[$ansid]["username"];
		$answer = $answers[$ansid]["answer"];

		echo "Author: ".$author."<br><br>";

	echo "<img src=data/img/".$author."_".$qid."><br>";
	echo nl2br($answer);
	?>
	<p align=right>
	<a href=ansview.php?r=<?php echo $ansid; ?>&c=up>Like</a> --
	</p>
	<iframe width=300 height=50 frameborder=0 src=comment.php?r=<?php echo $ansid; ?>>
	</iframe>
	</div>
</div>
</body>
</html>
