Online Stats

Detox

Member
Jul 24, 2010
365
24
I need to change this code
PHP:
<?php
$getTime = mysql_query("SELECT * FROM users_stats ORDER BY Respect DESC LIMIT 5") or die(mysql_error());
    while($timeStats = mysql_fetch_array($getTime))
        {
            $days = floor($timeStats['online_seconds'] / (60*60*24));
            $userInfo = mysql_fetch_array(mysql_query("SELECT `username`,`look` FROM users WHERE `id` = '".$timeStats['id']."'")); {
echo '
<tr>
<td width="25%"><img src="https://game.boon.pw/habbo-imaging/avatarimage.php?figure=' . $userInfo['look'] . '&size=m&direction32&head_direction=3&gesture=sml" align="left"></td>
<td width="75%"><a href="{url}/home/'.$timeStats['username'].'"><b>'.$userInfo['username'].'</b></a><br />'.$timeStats['online_seconds'].' Online</td>
</tr>';
}
}
?>

To make it show
mins,hours,days
 

Evilsmoothie

Mad kung-fu artist
Feb 11, 2013
446
57
Since I'm a real retard sometimes I did this to my profiles..
First I got my good old stats from the database
PHP:
                                         $stats = mysql_query("SELECT * FROM users_stats WHERE id='$id'");
                                         $get1 = mysql_fetch_assoc($stats);
Then I decided to be a little dirty and I did this
PHP:
$ontime = $get1['online_seconds'];
Then I found the spot on the site I wanted the stuff to show and did this
PHP:
                                         <?php
                                          function secondsToWords($seconds)
                                          {
                                              $ret = "";
                                              $days = intval(intval($seconds) / (3600*24));
                                              if($days> 0)
                                              {
                                                  $ret .= "$days Days ";
                                              }
                                              $hours = (intval($seconds) / 3600) % 24;
                                              if($hours > 0)
                                              {
                                                  $ret .= "$hours Hours ";
                                              }
                                              $minutes = (intval($seconds) / 60) % 60;
                                              if($minutes > 0)
                                              {
                                                  $ret .= "$minutes Min ";
                                              }
                                              return $ret;
                                          }
                                          print secondsToWords($ontime); ?>

Should you do it this way? Probably Definitely not, but it fucking worked so I didn't give a shit. (It's not what you asked for, but it sure is alot closer than nothing.)
 

Evilsmoothie

Mad kung-fu artist
Feb 11, 2013
446
57
This is complicated!
D: Just pull the seconds from the database and do this then:
PHP:
function secondsToWords($seconds)
                                          {
                                              $ret = "";
                                              $days = intval(intval($seconds) / (3600*24));
                                              if($days> 0)
                                              {
                                                  $ret .= "$days Days ";
                                              }
                                              $hours = (intval($seconds) / 3600) % 24;
                                              if($hours > 0)
                                              {
                                                  $ret .= "$hours Hours ";
                                              }
                                              $minutes = (intval($seconds) / 60) % 60;
                                              if($minutes > 0)
                                              {
                                                  $ret .= "$minutes Min ";
                                              }
                                              return $ret;
                                          }
                                          print secondsToWords($pulledsecondsfromdatabasehere);
 

Users who are viewing this thread

Top