<h1>Immobilien Wohnen</h1>
<h2>Bitte wählen Sie die gewünschte Kategorie</h2>

<?php
	$sqlr		= 'SELECT Kurz FROM ObR WHERE Wert = "on" AND Sektion = "wohnen";';
	$resultr	= $db->query($sqlr);
	
	while ($ntr = $resultr->fetch_assoc()) {
		if ("wm" == $ntr['Kurz']) {
			$sql1		= 'SELECT ID FROM objekte WHERE Aktiv = 1 AND O_TYP = "Wohnung" AND V_TYP = "Miete" ORDER BY ID ASC';
			$result1	= $db->query($sql1);
			$anzahl1	= $result1->num_rows;
			$nt1		= $result1->fetch_assoc();
			echo "\n";
			echo "<div class=\"haupt\">\n";
			echo "<table> \n";
			echo "    <colgroup>\n";
			echo "        <col width=\"100px\" />\n";
			echo "        <col width=\"320px\" />\n";
			echo "    </colgroup>\n";
			echo "    <tr>\n";
			echo "        <td rowspan=\"2\">\n";
			$file = "img/objekte/".$nt1['ID']."_1.jpg";
			if (file_exists($file)) {
				echo "<a style=\"color:#FFFFFF;\" href=\"index.php?section=wohnen&t=wm\" class=\"nounder\"><img src=\"img/objekte/".$nt1['ID']."_1.jpg\" width=\"80px\" height=\"60px\" /></a>\n";
			}
			echo "</td>\n";
			echo "        <td><a style=\"color:#FFFFFF;\" href=\"index.php?section=wohnen&t=wm\" class=\"nounder\"><h1>Wohnungen zur Miete</h1></a></td>\n";
			echo "    </tr>\n";
			echo "    <tr>\n";
			echo "        <td><a style=\"color:#FFFFFF;\" href=\"index.php?section=wohnen&t=wm\" class=\"nounder\"><h2>Zur Zeit haben wir $anzahl1 Objekte</h2></a></td>\n";
			echo "    </tr>\n";
			echo "</table>\n";
			echo "</div>\n";
			echo "\n";
		} elseif ("wk" == $ntr['Kurz']) {
			$sql2 = 'SELECT ID FROM objekte WHERE Aktiv = 1 AND O_TYP = "Wohnung" AND V_TYP = "Kauf" ORDER BY ID ASC';
			$result2 = $db->query($sql2);
			$anzahl2 = $result2->num_rows;
			$nt2 = $result2->fetch_assoc();
			echo "<a href=\"index.php?section=wohnen&t=wk\" class=\"nounder\">\n";
			echo "<div class=\"haupt\">\n";
			echo "<table> \n";
			echo "    <colgroup>\n";
			echo "        <col width=\"100px\" />\n";
			echo "        <col width=\"320px\" />\n";
			echo "    </colgroup>\n";
			echo "    <tr>\n";
			echo "        <td rowspan=\"2\">\n";
			$file = "img/objekte/".$nt2['ID']."_1.jpg";
			if (file_exists($file)) {
				echo "<img src=\"img/objekte/".$nt2['ID']."_1.jpg\" width=\"80px\" height=\"60px\" />\n";
			}
			echo "</td>\n";
			echo "        <td><h1>Wohnungen zum Kauf</h1></td>\n";
			echo "    </tr>\n";
			echo "    <tr>\n";
			echo "        <td><h2>Zur Zeit haben wir $anzahl2 Objekte</h2></td>\n";
			echo "    </tr>\n";
			echo "</table>\n";
			echo "</div>\n";
			echo "</a>\n";
		} elseif ("hm" == $ntr['Kurz']) {
			$sql3 = 'SELECT ID FROM objekte WHERE Aktiv = 1 AND O_TYP = "Haus" AND V_TYP = "Miete" ORDER BY ID ASC';
			$result3 = $db->query($sql3);
			$anzahl3 = $result3->num_rows;
			$nt3 = $result3->fetch_assoc();
			echo "<a href=\"index.php?section=wohnen&t=hm\" class=\"nounder\">\n";
			echo "<div class=\"haupt\">\n";
			echo "<table> \n";
			echo "    <colgroup>\n";
			echo "        <col width=\"100px\" />\n";
			echo "        <col width=\"320px\" />\n";
			echo "    </colgroup>\n";
			echo "    <tr>\n";
			echo "        <td rowspan=\"2\">\n";
			$file = "img/objekte/".$nt3['ID']."_1.jpg";
			if (file_exists($file)) {
				echo "<img src=\"img/objekte/".$nt3['ID']."_1.jpg\" width=\"80px\" height=\"60px\" />\n";
			}
			echo "</td>\n";
			echo "        <td><h1>Häuser zur Miete</h1></td>\n";
			echo "    </tr>\n";
			echo "    <tr>\n";
			echo "        <td><h2>Zur Zeit haben wir $anzahl3 Objekte</h2></td>\n";
			echo "    </tr>\n";
			echo "</table>\n";
			echo "</div>\n";
			echo "</a>\n";
		} elseif ("hk" == $ntr['Kurz']) {
			$sql4 = 'SELECT ID FROM objekte WHERE Aktiv = 1 AND O_TYP = "Haus" AND V_TYP = "Kauf" ORDER BY ID ASC';
			$result4 = $db->query($sql4);
			$anzahl4 = $result4->num_rows;
			$nt4 = $result4->fetch_assoc();
			echo "<a href=\"index.php?section=wohnen&t=hk\" class=\"nounder\">\n";
			echo "<div class=\"haupt\">\n";
			echo "<table> \n";
			echo "    <colgroup>\n";
			echo "        <col width=\"100px\" />\n";
			echo "        <col width=\"320px\" />\n";
			echo "    </colgroup>\n";
			echo "    <tr>\n";
			echo "        <td rowspan=\"2\">\n";
			$file = "img/objekte/".$nt4['ID']."_1.jpg";
			if (file_exists($file)) {
				echo "<img src=\"img/objekte/".$nt4['ID']."_1.jpg\" width=\"80px\" height=\"60px\" />\n";
			}
			echo "</td>\n";
			echo "        <td><h1>Häuser zum Kauf</h1></td>\n";
			echo "    </tr>\n";
			echo "    <tr>\n";
			echo "        <td><h2>Zur Zeit haben wir $anzahl4 Objekte</h2></td>\n";
			echo "    </tr>\n";
			echo "</table>\n";
			echo "</div>\n";
			echo "</a>\n";
		}
	}
?>