<?php
require_once("config_sql.php");
$result = mysql_query("SELECT * FROM `favorites` WHERE kamerid='".$_GET['kamerid']."' AND member='".$_GET['jouwnaam']."';");
if (mysql_num_rows($result) >= 1)
{
}
else
{
	mysql_query("INSERT INTO `favorites` SET kamerid='".$_GET['kamerid']."', member='".$_GET['jouwnaam']."';");
}
echo '<table border="0" cellpadding="0" cellspacing="0">';
echo "<tr>";
echo "<td colspan='5' height='6'></td>";
echo '</tr>';
$csql = "SELECT * FROM `favorites` WHERE member='".$_GET['jouwnaam']."';"; 
$cres = mysql_query($csql); 
if (mysql_num_rows($cres) >= 1) 
{
	while ($row = mysql_fetch_array($cres)) 
    {
	    $favoriet = "ja";
		$favo_naam = halen("SELECT naam FROM kamers WHERE id='".$row['kamerid']."';");
	    $favo_omschrijf = halen("SELECT omschrijf FROM kamers WHERE id='".$row['kamerid']."';");
	    $favo_type = halen("SELECT type FROM kamers WHERE id='".$row['kamerid']."';");
	    $favo_safe = halen("SELECT safe FROM kamers WHERE id='".$row['kamerid']."';");
	    $favo_eigenaar = halen("SELECT eigenaar FROM kamers WHERE id='".$row['kamerid']."';");
	    $favo_pass = halen("SELECT pass FROM kamers WHERE id='".$row['kamerid']."';");
	    $favo_id = halen("SELECT id FROM kamers WHERE id='".$row['kamerid']."';");
		echo "<tr>";
		echo "<td><img src='images/navi/links.gif'></td>";
		echo "<td onclick=\"kamer('".$favo_naam."', '".$favo_omschrijf."', '".$favo_type."', '".$favo_safe."', '".$favo_eigenaar."', ".$favo_id.", '".$favoriet."', '".$favo_pass."');\" width=\"227\" bgcolor=\"#DADADA\"><div class='clientfont'><img src='images/navi/sloten/".$favo_safe.".gif'>&nbsp;".$favo_naam."</div></td>";
		echo "<td><img src='images/navi/rechts.gif'></td>";
		echo "<td width='2'><font color='black' size='2'>&nbsp;</font></td>";
		echo "<td><a onclick=\"gaklik('".$favo_naam."', '".$favo_omschrijf."', '".$favo_type."', '".$favo_safe."', '".$favo_eigenaar."', ".$favo_id.", '".$favoriet."', '".$favo_pass."');\"><img src='images/navi/ga.gif' border='0' style='cursor: default;'></a></td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan='5' height='2'></td>";
		echo "</tr>";
	}
}
else
{
	echo "<table border='0' cellpadding='0' cellspacing='0'>";
	echo "<tr>";
	echo "<td colspan='2' height='8'></td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td width='8'></td>";
	echo "<td>";
	echo "<div class='clientfont'>";
	echo "Je hebt nog geen favoriete kamers.";
	echo "</div>";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
}
echo "</table>";
?>