Here's an update to the webpage. Added a bit more styling.
PHP Code:
<?php
$config = array(
'host' => 'localhost', //Database host
'username' => 'username', //Database username
'password' => 'password', //Database password
'dbname' => 'database', //Database name
'perpage' => 20, //Amount of bans to show per page
);
//---------
mysql_connect($config['host'], $config['username'], $config['password']) or die('Couldn\'t connect to the database.');
mysql_select_db($config['dbname']) or die('Couldn\'t select the database.');
$currentPage = empty($_GET['page'])||!is_numeric($_GET['page'])||$_GET['page']<1?1:(int)$_GET['page'];
$query = mysql_query('SELECT * FROM `my_bans` ORDER BY `id` DESC LIMIT '.(($currentPage-1)*$config['perpage']).','.$config['perpage']);
$pageResults = mysql_num_rows(mysql_query('SELECT * FROM `my_bans`'));
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>MySQL Bans</title>
<style type="text/css">
body {
background: #fff;
}
#table-b
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 45px;
width: 480px;
text-align: left;
border-collapse: collapse;
border: 1px solid #69c;
}
#table-b th
{
padding: 15px 10px 10px 10px;
font-weight: normal;
font-size: 14px;
color: #039;
}
#table-b tbody
{
background: #e8edff;
}
#table-b td
{
padding: 10px;
color: #669;
border-top: 1px dashed #fff;
}
#table-b tbody tr:hover td
{
color: #339;
background: #d0dafd;
}
tfoot {
display: table-footer-group;
border-color: inherit;
text-align: left;
}
</style>
</head>
<?php
if(mysql_num_rows($query) == 0){
echo 'No players currently on the banlist...';
}else{
?>
<table id="table-b">
<thead>
<tr>
<th scope="col">Steam ID:</th>
<th scope="col">Player Name:</th>
<th scope="col">Ban Reason:</th>
<th scope="col">Banned By:</th>
<th scope="col">Ban Length:</th>
<th scope="col">Time:</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5"><em>Pagination would look good here, except I know not how to do it.</em></td>
<td class="tfoot"> </td>
</tr>
</tfoot>
<?php
while($row = mysql_fetch_assoc($query)){
echo '<tr><td>',$row['steam_id'],'</td><td>',htmlentities($row['player_name'], ENT_QUOTES, "UTF-8"),'</td><td>',htmlentities($row['ban_reason']),'</td><td>',htmlentities($row['banned_by'], ENT_QUOTES, "UTF-8"),'</td><td>',$row['ban_length'],'</td><td>',$row['timestamp'],'</td></tr>';
}
echo '</table>';
if($pageResults>$config['perpage']){
$pageUrl = '?page=';
if($currentPage>1){
echo '<a href="',$pageUrl,($currentPage-1),'">Previous</a> ';
}
$totalPages = ceil($pageResults/$config['perpage']);
for($i=1;$i<=$totalPages;++$i){
echo '<a href="',$pageUrl,$i,'">',$i,'</a> ';
}
if($currentPage<$totalPages){
echo '<a href="',$pageUrl,($currentPage+1),'">Next</a> ';
}
}
}
?>
</body>
</html>
I do not know how to put the pagination stuffs in the table footer, so if someone can fix that up it'll be even better.