[Web]Ranklist SQL Cache PHP

05/11/2013 12:40 TraxWall#1
Hey.

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';

$rankingsreload86400// 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
}
}
?>
I hope it was helpful :)
:mofo: :o :)
05/11/2013 13:01 Stαgє6#2
Hmm.. this file rankingsreload_cache.txt is missing..
05/11/2013 13:02 -TÜRK-#3
I think, there we have lot of hp script with sql cache ranklist...

You can do this job with ob_get_contents also.
05/11/2013 13:06 TraxWall#4
Quote:
Originally Posted by TheSonny View Post
Hmm.. this file rankingsreload_cache.txt is missing..
You do not need it and I'll run it by itself is made up: D