BattleTracker
PhP & MySQL webpage example
Code Example
- Copy this and enter MySQL info to access a quick stats webpage
<em><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="BattleArena" content="BattleArena" />
<meta name="BattleArena" content="Minecraft,BattleArena" />
<meta name="BattleArena" content="BattleArena" />
<title>Battletracker</title>
<style type="text/css">
table.hovertable {
font-family: verdana,arial,sans-serif;
font-size:14px;
color:#c4b59f;
border-width: 1px;
border-color: #0D0D0D;
border-collapse: collapse;
width:100%;
}
table.hovertable th {
color:#cf7d3a;
background-color:#080808;
border-width: 1px;
padding: 10px;
border-style: solid;
border-color: #0D0D0D;
}
table.hovertable tr {
background-color:#080808;
}
table.hovertable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #0D0D0D;
text-align:center;
}
table.hovertable tr:hover { background-color: #0D0D0D; }
</style>
</head>
<?php
/* ENTER YOUR MYSQL INFO BELOW */
$db_host = 'xxxxxx';
$db_user = 'xxxx';
$db_pass = 'xxxx';
$db_database= 'xxx';
/* END MYSQL */
$link = mysql_connect($db_host,$db_user,$db_pass) or die('Unable to establish a DB connection');
?>
<body>
<div align="center">
<?
$rank = 1 ; $page = 1 ;
$limitvalue = $page * $limit - ($limit); $limit = 35 ; // (( Amount to display per page )) //
echo '<table class = "hovertable">';
echo "<tr> <th> PvP Rank </th><th> Player Name </th> <th> Kills </th> <th> Deaths </th> <th> Rampage </th> <th> PK ELO </th> </tr>" ;
if (!$link) die ("Could not connect MySQL");
mysql_select_db($db_database,$link) or die ("Could not open database");
$result=mysql_query("SELECT * FROM bt_PvP_overall ORDER BY Elo DESC LIMIT $limitvalue, $limit") or die("Error: " . mysql_error()); $num_rows =mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
$name = $row[Name];
$wins = $row[Wins];
$losses = $row[Losses];
$streak = $row[Streak];
$elo = $row[Elo];
echo " <td> $rank </td> <td> $name </td> <td> $wins </td> <td> $losses </td> <td> $streak </td> <td> $elo </td>
</tr>" ;
$rank = $rank + 1 ;
}
echo '</table>';
?>
</div>
</body>
</html>
</em>