- Joined
- Mar 30, 2007
- Messages
- 745
- Reaction score
- 34
Ultra simple ranking script, easy to build more on, and customize the layout of.
Uses ODBC, so easier than fiddeling with MSSQL.
ranking.php
ranking.tpl
Uses ODBC, so easier than fiddeling with MSSQL.
ranking.php
PHP:
<?php
// configuration
$config = array(
'db_username' => 'sa', // database username
'db_password' => '', // database password
'db_dsn' => 'hoax', // system DSN to the database
'template' => 'ranking.tpl', // registration template path/filename
);
$conn = odbc_connect(
$config['db_dsn'],
$config['db_username'],
$config['db_password']
);
$classes = array(
0 => 'Knight',
1 => 'Mage',
2 => 'Archer'
);
$sql = "SELECT
Player.Level,
Player.Class,
Player.Name,
Guild.Name AS GuildName
FROM
Player
LEFT JOIN
Guild
ON
Guild.GID = Player.GID
WHERE
Player.Admin = 0
ORDER BY
Player.Level DESC,Player.Exp DESC
";
class Player {}
$players = array();
$exec = odbc_exec($conn,$sql);
while($data = odbc_fetch_array($exec))
{
$player = new Player();
$player->Name = $data['Name'];
$player->Level = $data['Level'];
$player->Guild = $data['GuildName'];
$player->ClassName = $classes[$data['Class']];
$players[] = $player;
}
require_once($config['template']);
?>
ranking.tpl
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Ranking </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
font-family: verdana;
font-size: 11px;
}
</style>
</head>
<body>
<form action="" method="post">
<table>
<thead>
<tr>
<th>Level</th>
<th>Name</th>
<th>Class</th>
<th>Guild</th>
</tr>
</thead>
<tbody>
<?php foreach($players as $player): ?>
<tr>
<td><?php echo $player->Level; ?></td>
<td><?php echo $player->Name; ?></td>
<td><?php echo $player->ClassName; ?></td>
<td><?php echo $player->Guild; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</form>
</body>
</html>
Last edited: