<!DOCTYPE html>
<html>
<head>
    <title>DataBus - ShowLine</title>
    <?php include 'modules/head.php'; ?>
</head>
<body>
<?php include 'modules/nav.php'; ?>

<h1>ShowLine</h1>
<p>Here you can find a list of routes that have a specified line number. Click 
on a route's name to see a list of its bus stops and the position of the bus 
on the map.</p>



<?php
include 'modules/libdata.php';

if (isValidLine($_GET["line"])){
    echo '<header><h1>Line ' . $_GET["line"] . '</h1></header>';
    PrintRoutes($_GET["line"]);
} else {
    echo '<span style="display:inline-block" class="alert alert-danger" role="alert">No such line. <a href="javascript:history.back()">Go back?</a></span>';
}

function PrintRoutes($line){
    $routes = getRoutesOfLine($line);
    echo '<table class="table table-striped table-bordered"><thead><tr>';
    echo '<th>Route #</th><th>Route Name</th>';
    echo '</tr></thead><tbody>';
    foreach ($routes as $route){
        echo '<tr><td>' . $route['id'] . '</td>';
        echo '<td><a href="ShowRoute.php?route=' .  $route['id'] . '">' . $route['name'] . '</a></td></tr>';
    }
    echo '</tbody></table>';
}
?>



<?php include 'modules/foot.php'; ?>
</body>
</html


