<!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>Auswahl einer Linie und Ausgabe der Linienfarbe, geordnet nach der Reihenfolge</title>";
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
echo "</head>";
echo "<body>";
echo "<h2>Auswahl einer Linie und Ausgabe der Linienfarbe, geordnet nach der Reihenfolge</h2>";
echo "<form action='' method='post'>";
echo "Linie :";
echo "<select name='umfrage'>";
mysqli_select_db($dz, 'goettingen');
$sql = mysqli_query($dz, "SELECT DISTINCT idline FROM statline");
while ($ds = mysqli_fetch_object($sql)){
  $number = $ds -> idline;
  $idline[]=$number;
  }
$anzahl = count($idline);
for ($i = 0; $i < $anzahl; $i++){
  echo "<option value=\"$i\">$idline[$i]</option>";
  }	
echo "</select>";
echo "<input type='submit' value='Auswählen'>";
echo "</form>";
if (array_key_exists('umfrage',$_POST)) {
$line= $idline[$_POST['umfrage']];
$query="
SELECT stations.name AS 'Haltestelle', statline.ridesequence AS 'Reihenfolge', line.color AS 'Farbe', hexa
FROM stations, statline, line
WHERE statline.IDLine ='". mysqli_real_escape_string($dz, $line) ."'
AND line.id ='". mysqli_real_escape_string($dz, $line) ."'
AND stations.ID = statline.idstations
ORDER BY statline.ridesequence ASC;";
$result=mysqli_query($dz, $query);
} else {
	$line ='';
}

if ($line != ""){
  while ($ds = mysqli_fetch_object($result)){
/*    $Linie 			= $ds -> Linie;*/
    $Haltestelle 	= $ds -> Haltestelle;
    $Reihenfolge 	= $ds -> Reihenfolge;
    $hexa           = $ds -> hexa;
	echo 
	"<table border=0>
	<tr>
	<td width=20 height=20 bgcolor=$hexa><font color=white><b>$Reihenfolge</b></font></td>
	<td width=200 height=20><b>$Haltestelle</b></td>
	</tr>
	</table>";	
	}
  mysqli_close($dz);
  } 
echo "</body>";
?>
