<?php

function setComments($conn) {
	if (isset($_POST['commentSubmit'])) {
	$uid = $_POST['uid'];
	$date = $_POST['date'];
	$location = $_POST['location'];
	$message = $_POST['message'];

	$sql = "INSERT INTO comments (uid, date, location, message) VALUES ('$uid', '$date', '$location', '$message')";
	$result = mysqli_query($conn, $sql);
	}	
}

function getComments($conn) {
	$sql = "SELECT * FROM comments ORDER BY date DESC ";
	$result = mysqli_query($conn, $sql);
	while ($row = mysqli_fetch_assoc($result)) {
		echo"<div class='comment-box' onmouseover='playHoverSound()'><p>";
			echo $row['uid']."<br>";
			echo $row['date']."<br>";
			echo $row['location']."<br><br>";
			echo nl2br($row['message']);
		echo "</p></div>";
	}
}

?>
