<?php
// ab17.php - Wie lange ist die maximale Fahrtzeit auf einer zu w&auml;hlenden Linie? 

include 'header.php';


// ############ START QUERY ############################################################
if(isset($_POST['linie'])) {
   $gew_linie = $_POST['linie'];
} else {
   $gew_linie = '';
}


$abfrage_fahrzeit = "
SELECT routes_stations.duration
FROM routes_stations, routes
WHERE routes.name = '$gew_linie' AND routes.id = routes_stations.r_id
ORDER BY routes_stations.duration DESC 
LIMIT 1
";
$ergebnis_fahrzeit = mysqli_query($db, $abfrage_fahrzeit) OR DIE ("Anfrage fehlgeschlagen: " . mysqli_error($db));

   
   
echo '</head>';
// ############ START BODY ############################################################
echo '<body>';

include 'menu.php';


// ############ START CONTENT ############################################################
echo '
   <div id="content">
   <a href="abfragen.htm" class="menulink">zur&uuml;ck zu den Abfragen</a>
';   

echo "<h1>Wie lange ist die maximale Fahrtzeit auf einer zu w&auml;hlenden Linie?</h1>";

echo "<form method=\"post\" action=\"ab17.php\">";
echo '<select name="linie" size="1"><option value="Linie 1">Linie 1<option value="Linie 2">Linie 2<option value="Linie 3">Linie 3<option value="Linie 4">Linie 4<option value="Linie 5">Linie 5<option value="Linie 6">Linie 6<option value="Linie 7">Linie 7<option value="Linie 8">Linie 8<option value="Linie 9">Linie 9<option value="MAGLEV">MAGLEV</select>';
echo '&nbsp;<input type="submit" name="form_linie" value="Linie w&auml;hlen">';
echo '</form><br>';




if ($gew_linie == "") {
   echo '';
}
else {
   if ($gew_linie == "Linie 7") {
      echo "<b>$gew_linie</b> ist unter Konstruktion";
   }
   else {
      echo "Die Fahrtzeit auf der <b>$gew_linie</b> betr&auml;gt: ";

     while ($line = mysqli_fetch_array($ergebnis_fahrzeit, MYSQLI_ASSOC)) {
         foreach ($line as $col_value) {
            echo '<b>', $col_value, '</b> Minuten';
         }
      }
   }
}
   
   include 'footer.php';
?>
