Davie33 Posted April 8, 2014 Share Posted April 8, 2014 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(); ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted April 9, 2014 Share Posted April 9, 2014 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. Quote Link to comment Share on other sites More sharing options...
Davie33 Posted April 9, 2014 Author Share Posted April 9, 2014 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.