<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
<?php
require_once('mysql.inc.php');
echo "<head>";
echo "<title>Anzeigen der Sehensw&uuml;rdigkeiten nach Auswahl der Art der Sehensw&uuml;rdigkeit</title>";
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
echo "</head>";
echo "<body>";
echo "<h2>Anzeigen der Sehensw&uuml;rdigkeiten nach Auswahl der Art der Sehensw&uuml;rdigkeit</h2>";
echo "<form action='' method='post'>";
echo "Art :";	
mysqli_select_db($dz, 'goettingen');
$sql = mysqli_query($dz, "SELECT typ FROM ads");
while ($ds = mysqli_fetch_object($sql)){
  $type = $ds -> typ;
  $typ[]=$type;
  }
$anzahl = count($typ);
for ($i = 0; $i < $anzahl; $i++){
  echo "<input type = \"radio\" name=\"umfrage\" value=\"$i\">$typ[$i]";
  }
echo "<br>";
echo "<input type='submit' value='Auswählen'>";
echo "</form>";
if (array_key_exists('umfrage',$_POST)) {
$typ= $typ[$_POST['umfrage']];
$query="
SELECT ads.typ AS 'Art der Sehenswürdigkeit', sights.name AS 'Sehenswürdigkeit', address AS 'Adresse', discription AS 'Beschreibung'
FROM ads, sights
WHERE ads.id = sights.idads AND ads.typ = '". mysqli_real_escape_string($dz, $typ) ."';";
$result=mysqli_query($dz, $query);
} else {
	$typ ='';
}
if ($typ != ""){
  echo "Sie haben als Typ: <b>$typ</b> gew&auml;hlt<br>";
  while ($ds = mysqli_fetch_object($result)){
    $sight	= $ds -> Sehenswürdigkeit;
	$address = $ds -> Adresse;
	$des = $ds -> Beschreibung;
	echo "<br>";
	echo "<b>$sight :</b><br>";
	echo " $address<br>";
	echo "$des<br><br>";
	}
  mysqli_close($dz);
  } 
echo "</body>";
?>
