<?
  $servername = "db";
  $username = 'kalskeborec';
  $password = 'Kalskeborec1!23$';
  $db = 'kalskeborec';
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $db);
  
  // Check connection
  if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
  }

  $sql = "SELECT ID, NAME, SURNAME, EMAIL, PHONE, NICK, RACE, TIME, TRACKLOG, EMAIL_CHECK, CONFIRMED, PAID FROM REGISTERED";
  $result = $conn->query($sql);
  if ($result->num_rows > 0){
    $table_registered = '';
    while($row = $result->fetch_assoc()) {
      $table_registered = $table_registered.'<tr>';
      $table_registered = $table_registered.'<td>'.$row["ID"].'</td><td>'.$row["NAME"].' '.$row["SURNAME"].'</td><td>'.$row["EMAIL"].'</td><td>'.$row["PHONE"].'</td>';
      $table_registered = $table_registered.'<td>'.$row["NICK"].'</td><td>'.$row["RACE"].'</td>';
      $table_registered = $table_registered.'<td>'.$row["TIME"].'</td><td>'.$row["TRACKLOG"].'</td>';
      $table_registered = $table_registered.'<td>'.$row["EMAIL_CHECK"].'</td><td>'.$row["CONFIRMED"].'</td><td>'.$row["PAID"].'</td>';
      $table_registered = $table_registered.'</tr>';
    }
  }else{
  echo "0 results";
  }
  $conn->close();
?>

<table class="w3-table w3-striped w3-bordered w3-border w3-white">
<tr>
  <th>ID</th>
  <th>Jméno</th>
  <th>Email</th>
  <th>Telefon</th>
  <th>Přezdívka / Team</th>
  <th>Závod</th>
  <th>Čas</th>
  <th>Log</th>
  <th>Email check link</th>
  <th>Potvrzeno</th>
  <th>Zaplaceno</th>
</tr>
<? echo $table_registered; ?>
</table>
