<div class="navh3">
  <div align="center">Favorite Games
  </div>
</div>
<div class="links1">
<?php
if(isset($_SESSION["user"])) { 
	$user = $_SESSION["user"]; 
	$userid = $_SESSION["userid"];
	$result = yasDB_select("SELECT id, file, title FROM games WHERE id IN (SELECT gameid FROM favourite WHERE userid= '$userid') LIMIT 5");
	$query = yasDB_select("SELECT * FROM favourite WHERE userid= '$userid' limit 5",false);
	while ($games = $result->fetch_array(MYSQLI_ASSOC)) {
		$gameurl = prepGame($games['title']);
		if ($setting['seo']=='yes') {
			echo'<a href="' . $setting['siteurl'] . 'game/' . $games['id'] . '/' . $gameurl . '.html' . '">' . $games['title'] . '</a>';
        }
		else {
			echo'<a href="' . $setting['siteurl'] . 'index.php?act=game&id=' . $games['id'] . '">' . $games['title'] . '</a>';
    	}
    }
	if ($query->num_rows == 0) {
			echo '</div>There are no games in your Favorites.';
	}
	else {
		if ($setting['seo']=='yes') {
			echo'<center><a href="' . $setting['siteurl'] . 'favourites.html">More</a></center></div>';
		}
		else {
			echo'<center><a href="' . $setting['siteurl'] . 'index.php?act=favourites">More</a></center></div>';
		}
	}
}
else {
	echo '</div>Log in to view your saved games list.';
}
?>