Jump to content

Stats help plz


Davie33

Recommended Posts

Hi am having a problem with my stats file.

 

this is my code for members online and guests.

this echo's members online

echo ' Members Online- ('.$online.') ';

and this echo's guests

echo ' Guests: (' . $total_visitors.')<br/>';

 

How do i get it to work when members online it will  -1 guests for each member that online?.

<?php
$active_length = 600;  // How many seconds to count an user as active until they access another page... 600 = 10 minutes
$query = yasDB_select("SELECT count(user.id) as count FROM user ");
$row = $query->fetch_array(MYSQLI_ASSOC);
$query->close();
echo 'Members - ('.$row['count'].') ';
$time = time()-$active_length;
$query = yasDB_select("SELECT user.username AS name, user.id AS id FROM user, membersonline WHERE membersonline.memberid = user.id AND timeactive >= '$time'");
$online = $query->num_rows;
echo ' Members Online- ('.$online.') ';
$visitors_online = new usersOnline();
$bots = array();
$bots = $visitors_online->get_bots();
$total_visitors = $visitors_online->count_users(); //grab the visitor count
echo ' Guests: (' . $total_visitors.')<br/>'; //display the count however you wish
if ($online > 0) {
    while ($row = $query->fetch_array(MYSQLI_ASSOC)) {
        if ($setting['seo'] == 'yes' ) {
            echo '<a href="'.$setting['siteurl'].'showmember/'.$row['id'].'.html">'.$row['name'].'</a> ';
        }
        else {
            echo '<a href="'.$setting['siteurl'].'index.php?act=showmember&id='.$row['id'].'">'.$row['name'].'</a> ';
        }
    }
}
$visitors_online = new usersOnline();
$bots = array();
$bots = $visitors_online->get_bots();
if ($bots) {
    foreach ($bots as $bot) {
        echo ucfirst($bot) . ' ';
    }
}
$query->close();
unset($row);
echo '<br>Welcome our newest Member:';
$query = yasDB_select("SELECT * FROM user ORDER BY id DESC LIMIT 1");
while($row = $query->fetch_array(MYSQLI_ASSOC)) {
    $id = $row['id'];
    $username = $row['username'];
    if ( $row['useavatar'] == '1' ) {
        $avatarimage = $setting['siteurl'] . 'avatars/' . $row['avatarfile'];
    }
    else {
        $avatarimage = $setting['siteurl'] . 'avatars/useruploads/noavatar.JPG';
    }
    if ($setting['seo'] == 'yes' ) {
        echo ' <a href="'.$setting['siteurl'].'showmember/'.$row['id'].'.html" title="'.$username.'">'.$username.'</a> ';
    } else {
        echo ' <a href="'.$setting['siteurl'].'index.php?act=showmember&id='.$row['id'].'" title="'.$username.'">'.$username.'</a> ';
    }
}
$query->close();
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/287622-stats-help-plz/
Share on other sites

Yes subtraction am talking about.Thank for your help it working so far,will need to test it when other visitors are on,thanks again :).

Are you talking about subtraction?

$total_visitors = max($visitors_online->count_users() - $online, 0);
max() just in case your database disagrees with usersOnline::count_users() about how many people are online.

 

Link to comment
https://forums.phpfreaks.com/topic/287622-stats-help-plz/#findComment-1475506
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.