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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.