Leaderboards - Diamonds topstats.php

Silver

Active Member
Aug 17, 2016
152
28
I am quickly putting up Most Diamonds for the leaderboards it came with Most Credits, Duckets, Referral Points and GOTW Points. I changed referral points to diamonds and now I want to change diamonds with most respects if someone could help me out with sharing a similar code.

Code:
        <div id="column" class="column" style="width:192px;">
<div class="habblet-container ">
<div class="cbb clearfix green ">
<h2 class="title"><span style="float: left;">Most Diamonds</span></h2>
<div align='left'>
<?php

  $mostdiamonds = mysql_query("SELECT username,vip_points,look FROM users WHERE rank < 2 ORDER BY vip_points DESC LIMIT 7");
  while($diamonds = mysql_fetch_assoc($mostdiamonds))

  {
echo'<table width="100%">
<tr>
<td width="25%">
<img src="http://www.habbo.nl/habbo-imaging/avatarimage?figure=' . $diamonds['look'] . '&headonly=1&gesture=sml"" align="left"></td>
                                    <td width="75%"><a href="{url}/home/' . $diamonds['username'] . '"><b>' . $diamonds['username'] . '</b></a><br />' . bd_nice_number ($diamonds['vip_points']) . ' Diamonds</td>
                                </tr>
                            </table>
                            <hr>';
}
?>
</div>
                </div>
            </div>
            <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
        </div>
 

Joe

Well-Known Member
Jun 10, 2012
4,090
1,918
Thread moved to Habbo Help & Support.

I found an old CMS that has all of those in, you could try it out and tweak it to how you want it. The code is old and I haven't used it recently, so..
Code:
<div class="habblet-container">
                    <div class="cbb clearfix blue ">
                        <h2 class="title">Most Respects</h2>
                        <div class="box-content">                                                   

                        <?php
                      
                                    $userstats_a = mysql_query("SELECT * FROM user_stats ORDER BY Respect DESC LIMIT 10");
                                    while($userstats = mysql_fetch_assoc($userstats_a)){
                                    $row = mysql_fetch_assoc($row = mysql_query("SELECT * FROM users WHERE id = '".$userstats['id']."' LIMIT 7"));
                                  
                            if($row['online'] == 1){ $OnlineStatus = "<div style='float: left;'><img src='{url}/app/tpl/skins/Habbo/images/habbo_online_anim.gif' title='Offline'></div>"; } else { $OnlineStatus = "<div style='float: left;'><img src='{url}/app/tpl/skins/Habbo/images/habbo_offline.gif' title='Offline'></div>"; }
                          
                        ?>
                      
                        <div style="width: 33px; float: left;">
                            <img src="http://www.habbo.it/habbo-imaging/avatarimage?figure=<?php echo $row['look']; ?>&size=s&direction=2&head_direction=3&gesture=sml&size=m" align="left">
                        </div>
                      
                        <div style="height: 56px; width: 180px; float: left;">
                            <p><?php echo $OnlineStatus ?><div style="margin-top: 2px;"><strong>&nbsp;<a href="{url}/home/<?php echo $row['username']; ?>"><?php echo $row['username']; ?></a></strong></div><br />
                            <div style="margin-top: -7px;"><?php echo number_format($userstats['Respect']); ?> Respects.</div></p>
                        </div>
                      
                        <?php } ?>
                        </div>
                    </div>
                </div>
 

Core

Member
Nov 10, 2016
356
138
An easier method would be to use a joint query :p

Code:
$mostRespect = mysql_query("SELECT usr.id, usr.username, usr.look, stat.Respect FROM users usr JOIN user_stats stat ON stat.id = usr.id WHERE usr.rank < 2 ORDER BY stat.Respect DESC")
        or die(mysql_error());

This is a much cleaner and faster method. Also allows for more control over your query for example limiting users rank to not display staff.
 

Users who are viewing this thread

Top