<html>
    <head>
        <meta http-equiv="refresh" content="15">
    </head>
    <body style="background-image: url('./style/images/fabric-pattern.png')">
        <?php

        $statement = $RUNTIME['PDO']->prepare("SELECT UserID,RegionID FROM Presence WHERE RegionID != '00000000-0000-0000-0000-000000000000' ORDER BY RegionID ASC");
        $statement->execute(); 

        if($statement->rowCount() == 0)
        {
            echo "<h1>Es ist niemand online!</h1>";
        }else{

            echo '<table style="width:350px;margin-left:auto;margin-right:auto;margin-top:25px"><tr><th align="left" style="background-color: #FF8000;">Name</th><th align="left" style="background-color: #FF8000;">Region</th></tr>';
            $entryColor = TRUE;
            include 'app/OpenSim.php';
            $opensim = new OpenSim();
            while($row = $statement->fetch()) 
            {
                if($entryColor == TRUE)
                $entry = '<tr style="background-color: #F2F2F2;"><td>'.trim($opensim->getUserName($row['UserID'])).'</td><td>'.$opensim->getRegionName($row['RegionID']).'</td></tr>';

                if($entryColor == FALSE)
                    $entry = '<tr style="background-color: #E6E6E6;"><td>'.trim($opensim->getUserName($row['UserID'])).'</td><td>'.$opensim->getRegionName($row['RegionID']).'</td></tr>';

                echo $entry;
                $entryColor = !$entryColor;
            }

            echo '</table>';
        }
        ?>
    </body>
</html>