• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Tutorial] How to make money ranking?

Junior Spellweaver
Joined
Jun 5, 2011
Messages
180
Reaction score
205
It's easy as hell so it's not worth to put in release section.
You can also change it to any item ranking.

It's only remaded player ranking.
PHP:
<?php
// table style
DEFINE("STYLE", "font: 12px Verdana, Geneva, sans-serif; color: black; text-align; center;");
  $config = array(
    'db_username' => '', // database username
    'db_password' => '',   // database password
    'db_dsn'      => '',   // system DSN to the database
    'debug'       => false,
);



        $conn = odbc_connect($config['db_dsn'],
                             $config['db_username'],
                             $config['db_password']);
  
  $top = 1;
  $plist = "SELECT TOP 100 Player.Name, Player.Level, Player.Specialty, Item.Num, Player.Class
	FROM Player
	LEFT JOIN Item
	ON Player.PID=Item.PID
        WHERE
            [Index] = 31 
        ORDER BY
            Item.Num DESC";
  $pplist = odbc_exec($conn,$plist);
  
    echo '<br><br><br>';
    echo '<center><table width="400px" style="STYLE">';
	echo '<tr style="text-align: center">
	<td width="100px"><b>Rank</b></td>
	<td width="100px"><b>Name</b></td>
	<td width="100px"><b>Gold</b></td></tr>';

	while($r = odbc_fetch_array($pplist)){
		echo '<tr style="text-align: center"><td>'.$top.'</td><td>'.$r['Name'].'</td><td>'.$r['Num'].'</td></tr>';
		$top++;
	}
	
	echo '</table>';

?>
 
Custom Title Activated
Loyal Member
Joined
Apr 5, 2008
Messages
1,325
Reaction score
133
tnx it saves some time ^^ i allready made egg ranking so the money ranking will be good:) but i think players wanna keep that infos private:)
 
Newbie Spellweaver
Joined
Apr 16, 2009
Messages
87
Reaction score
22
First of all, I have noticed that this is not exactly the best way to go about doing... anything, So I propose a simple few corrections:

at the top of your code, inside your <head> element, you can set the CSS to style objects rather than defining it within the PHP itself.
Code:
<style type="text/css">
#rank
{
    position:absolute;
    font-family: Sans-serif, Geneva, Veranda;
    font-size: 12px;
    color:#000;
    text-align:center;
    width:400px;
    left:50%;
    bottom:50%;
}

#rank > tr
{
    text-align: center;
}

#rank > tr > td
{
    width:100px;
}
</style>

This not only corrects the errors in the original post, but speeds up the rest of the submission, as PHP will not need to define another object that it does not need to

PHP:
<?php 
  $config = array( 
    'db_username' => 'Username\SQLEXPRESS',
    'db_password' => 'Database password',
    'db_dsn'      => 'DSN for database as defined in ODBC',
    'debug'       => false, 
); 

        $conn = odbc_connect($config['db_dsn'], 
                             $config['db_username'], 
                             $config['db_password']); 
   
  $top = 1; 
  $plist = "SELECT TOP 100 Player.Name, Player.Level, Player.Specialty, Item.Num, Player.Class 
    FROM Player 
    LEFT JOIN Item 
    ON Player.PID=Item.PID 
        WHERE 
            [Index] = 31  
        ORDER BY 
            Item.Num DESC"; 
  $pplist = odbc_exec($conn,$plist); 
?>

After this, again, PHP was echoing HTML, this isn't always considered "Good Practice" and can really annoy the more hardcore developers of the language.
Code:
<br /><br /><br />
<table id="rank">
    <tr> 
        <td><strong>Rank</strong></td> 
        <td><strong>Name</strong></td> 
        <td><strong>Gold</strong></td>
    </tr>

PHP:
<?php
    while($r = odbc_fetch_array($pplist))
    { 
        echo '<tr><td>'.$top.'</td><td>'.$r['Name'].'</td><td>'.$r['Num'].'</td></tr>'; 
        $top++; 
    } 
?>
and to finish:
Code:
    </table>

Now, hopefully I have not messed it completely up, the PHP was left nearly the same throughout, as was the SQL. I merely modified the CSS to increase processing speed and to make the PHP script less of a mess.
 
Newbie Spellweaver
Joined
Feb 18, 2024
Messages
5
Reaction score
0
hello, how iam can use this on ranking beshoy ? someone can send me a exemple ?
 
Back
Top