I created a test rankings, which stores it in a file.
This is a test that has not been resolved to number them: S
But who knows who also make'd be happy
source:
PHP Code:
<?php
echo "<table border=\"0\" width=\"230\">
<tr>
<td width=\"150\"><b>Name</b></td>
<td width=\"30\"><b>Level</b></td>
</tr>";
?>
<?php
$file = 'rankingsreload_cache.txt';
$rankingsreload= 86400; // 24 hours
if (file_exists($file) &&
filemtime($file) > (time() - $rankingsreload)) {
$rankingsrecords = unserialize(file_get_contents($file));
} else {
$link = mysql_connect('ip','user','password')
or die (mysql_error());
mysql_select_db('player')
or die (mysql_error());
/* form SQL query */
$query = "SELECT id,name,level,exp,account_id FROM player WHERE name NOT LIKE '[%]%' ORDER BY level desc, exp desc, name asc limit 10";
$result = mysql_query($query)
or die (mysql_error());
while ($rankingsrecord = mysql_fetch_array($result) ) {
$rankingsrecords [] = $rankingsrecord;
}
$OUTPUT = serialize($rankingsrecords);
$fp = fopen($file,"w");
fputs($fp, $OUTPUT);
fclose($fp);
} // end else
// Query results are in $rankingsrecords array
foreach ($rankingsrecords as $id=>$row) {
if ($row['name'] == $_REQUEST['name']) {
?>
<?php
// name selected - print bold
print '<B>'.$row['name'].' '.$row['level'].'</B><br>';
} else {
// other name - print regular
?>
<tr>
<th width="187"><?php print $row['name'];?></th>
<th width="30"><?php print $row['level'];?></th>
</tr>
<?php
}
}
?>






