| id |
username |
Date of Visit |
| 1 | emanuel | 2017-08-21 15:02:58 |
| 2 | Hans | 2017-08-21 15:17:33 |
| 3 | Mr. Speaker | 2017-08-21 15:19:07 |
| 4 | emanuel | 2017-08-21 15:23:52 |
| 5 | emanuel | 2017-08-21 15:23:58 |
| 6 | emanuel | 2017-08-21 15:27:59 |
| 7 | emanuel | 2017-08-21 15:28:04 |
| 8 | emanuel | 2017-08-21 15:33:20 |
<?php
include "config.php";
$sql = "SELECT id, username, reg_date FROM visits";
$result = mysqli_query($db, $sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Database Table Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>code {background-color:#D3D3D3;}</style>
</head>
<body>
<div class="container">
<table class="table">
<thead>
<tr>
<th>id</th>
<th>username</th>
<th>Date of Visit</th>
</tr>
</thead>
<tbody>
<?php
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
//echo "id: " . $row["id"]. " - Username: " . $row["username"]. " Password: " . $row["passcode"]. "<br>";
echo "<tr><td>". $row["id"] . "</td><td>" . $row["username"] . "</td><td>". $row["reg_date"] ."</td></tr>";
}
} else {
echo "<tr><td colspan=\"3\">No entry found</td></tr>";
}
mysqli_close($db);
?>
</tbody>
</table>
</div>
<div class="container" style="background-color:#D3D3D3;">
<?php echo "<br>"; highlight_file("table.php"); //outputs the source code of this file to the web page ?>
</div>
</body>
</html>