<!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>Anzahl der haltenden Linien an einer Station</title>";
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
echo "</head>";
echo "<body>";
echo "<h2>Anzahl der haltenden Linien an einer Station</h2>
<table border=0>
<tr>
<td width=200 height=20><b>Haltestelle</b></td>
<td width=100 height=20><b>Anzahl Linien</b></td>
</tr>
</table>
";
mysqli_select_db($dz, 'goettingen');
$sql = mysqli_query($dz, "SELECT stations.name AS 'Haltestelle', COUNT( statline.idstations ) AS 'AnzahlLinien' 
FROM statline, stations
WHERE statline.idstations = stations.id
GROUP BY statline.idstations
HAVING count( statline.idstations ) >1
ORDER BY 1;
");
while ($ds = mysqli_fetch_object($sql)){
  $station = $ds -> Haltestelle;
  $count = $ds -> AnzahlLinien;
  echo 			
  "
  <table border=0>
  <tr>
  <td width=200 height=20>$station</td>
  <td width=100 height=20>$count</td>
  </tr>
  </table>";
  }	
mysqli_close($dz);
echo "</body>";
?>
