<?php
$data = new Config();

// Create connection
$conn = new mysqli($data->getSQLHost(), $data->getSQLUser(), $data->getSQLPassword(), $data->getSQLDatabase());
mysqli_set_charset($conn, "utf8");

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// output data of each row
?>
<section class="section--center mdl-grid mdl-grid--no-spacing">
    <div class="table-responsive">
        <h4 style="text-align: center">FMS-Status</h4>
        <table style="margin-left: auto; margin-right: auto" class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
            <thead>
            <tr>
                <th class="mdl-data-table__cell--non-numeric">Status</th>
                <th class="mdl-data-table__cell">Rettungsdienst</th>
                <th class="mdl-data-table__cell">Feuerwehr</th>
                <th class="mdl-data-table__cell">Polizei</th>
            </tr>
            </thead>
            <tbody>

            <?php

            $fms = $conn->query("SELECT * FROM `fms`");

            if($fms->num_rows > 0) {
                while ($row = $fms->fetch_assoc()) {
                    ?>
                    <tr>
                        <td class="mdl-data-table__cell"><?php echo $row['fms_status'] ?></td>
                        <td><?php echo $row['fms_rt'] ?></td>
                        <td><?php echo $row['fms_ff'] ?></td>
                        <td><?php echo $row['fms_pol'] ?></td>
                    </tr>
                    <?php
                }
            }
            ?>
            </tbody>
        </table>
    </div>
</section>