online status?

15 posts Page 1 of 2
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

online status?
Dummy1912
hello,
Code: Select all
$q = mysql_query("SELECT COUNT(*) FROM `users` WHERE ((`username`='$friend_id' AND `onlinestatus`='online') OR (`username`='$friend_id' AND `onlinestatus`='away'))");
            $n = mysql_num_rows($q); //COUNTS USERS ONLINE

            echo $n;
it count all users that are in the list
instead to calculated how many users are online , away , busy
and show it?

anyone a idea how to do it?

thanks
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Filip
Coding Guru
Coding Guru
Posts: 833
Joined: Wed Jan 05, 2011 3:59 pm

Re: online status?
Filip
Code: Select all
//Connection stuff
$total = 0;
$con = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
	if (!$con)
	  {
	  die('Error while trying to connect to db: ' . mysql_error());
	  }

	mysql_select_db(DB_NAME, $con);
	
	
	$result = mysql_query("SELECT `onlinestatus` FROM `users` WHERE `username`='$friend_id'") or die(mysql_error());
	$row = mysql_fetch_assoc($result);
	foreach($row as $content) {
        if ($content=='online') {
            $total++;
        }
        else if ($content=='away') {
            $total++;
        }

}
echo $total;
Last edited by Filip on Thu Feb 28, 2013 5:38 pm, edited 4 times in total.
CodenStuff wrote:
Nope, it's just your sick and dirty mind. You sick twisted warped little pervo :D
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: online status?
Dummy1912
hello filip,
thanks for reply.

but does not count?

lets say you have 10 friends
2 are offline

3 away
3 online
2 busy

so it will show : 8

you understand what i mean :D
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Filip
Coding Guru
Coding Guru
Posts: 833
Joined: Wed Jan 05, 2011 3:59 pm

Re: online status?
Filip
Oh sorry,

I misunderstood the question :D

I edited the code on first reply
CodenStuff wrote:
Nope, it's just your sick and dirty mind. You sick twisted warped little pervo :D
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: online status?
Dummy1912
hello #Filip
thanks again

but :( not working
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Filip
Coding Guru
Coding Guru
Posts: 833
Joined: Wed Jan 05, 2011 3:59 pm

Re: online status?
Filip
What is the error that you are getting?
CodenStuff wrote:
Nope, it's just your sick and dirty mind. You sick twisted warped little pervo :D
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: online status?
Dummy1912
no error just nothing to display :(
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Filip
Coding Guru
Coding Guru
Posts: 833
Joined: Wed Jan 05, 2011 3:59 pm

Re: online status?
Filip
There was a typo, try again.

Did you fill in the sql connection fields?
CodenStuff wrote:
Nope, it's just your sick and dirty mind. You sick twisted warped little pervo :D
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: online status?
Dummy1912
seems its not calculating it only show 1
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Filip
Coding Guru
Coding Guru
Posts: 833
Joined: Wed Jan 05, 2011 3:59 pm

Re: online status?
Filip
Try running
Code: Select all
SELECT `onlinestatus` FROM `users` WHERE `username`='put something here'
in phpMyAdmin and see the results
CodenStuff wrote:
Nope, it's just your sick and dirty mind. You sick twisted warped little pervo :D
15 posts Page 1 of 2
Return to “Help & Support”