Skip to content

Commit

Permalink
added result page
Browse files Browse the repository at this point in the history
  • Loading branch information
xathon committed Oct 6, 2020
1 parent 39aea7e commit 1026404
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
4 changes: 2 additions & 2 deletions css/bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ body {
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #212121;
background-color: #ffffff;
}

[tabindex="-1"]:focus:not(:focus-visible) {
Expand All @@ -77,7 +77,7 @@ h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
font-family: "Barlow Condensed", sans-serif;
color: #fff;
color: #000;
}

p {
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="row" style="height: 20em"></div>
<div class="row" style="height: 20em"></div>
<div class="row">
<div class="col-3">

Expand All @@ -26,6 +26,7 @@
</div>
<div class="col-6" style="text-align: center">
<a class="btn btn-primary" role="button" href="vote.php">Start</a>
<a class="btn btn-primary" role="button" href="output.php">Results</a>
</div>
</div>
</body>
Expand Down
77 changes: 77 additions & 0 deletions output.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
session_start();

//TODO seperate this into a snippet
require __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__, '.env');
$dotenv->load();
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'DB_PORT']);

$remote = mysqli_connect(getenv('DB_HOST'),
getenv('DB_USER'),
getenv('DB_PASS'),
getenv('DB_NAME'));
if (mysqli_connect_errno()) {
printf("Couldn't connect to database! %s\n", mysqli_connect_error());
exit();
}

$query = "select * from logocontest.output;";
$result = mysqli_query($remote, $query);


echo '<html>
<head>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="row">
<div class="col-2">
</div>
<div class="col-8" style="text-align: center">
<h1>Current ranking</h1>
</div>
</div>
<div class="row">
<div class="col-2">
</div>
<div class="col-8" style="text-align: center">
<table class="table">
<thead>
<th scope="col">Position</th>
<th scope="col">Logo</th>
<th scope="col">Name</th>
<th scope="col">Division</th>
<th scope="col">Won matchups</th>
</thead>
<tbody>
';
$count = 0;
$row = mysqli_fetch_assoc($result);
while ( $row!= NULL) {
echo '
<tr>
<th scope="row">'.++$count.'</th>
<td><img style="margin:20px" class="img-fluid" src="data:image/jpeg;base64,'.$row['logo'].'" width="50px" alt="'.$row['name'].'"></td>
<td>'.$row['name'].'</td>
<td>'.$row['region'].' '.$row['division'].'</td>
<td>'.$row['won_matchups'].'/'.$row['matchups'].'</td>
</tr>
';
$row = mysqli_fetch_assoc($result);
}
echo '
</tbody>
</table>
</div>
</body>
</html>'

?>


0 comments on commit 1026404

Please sign in to comment.