Hello,
I'm adding a feature to someone's website, and I have hit a snag -- I'm fairly "new" to PHP, I've only written a few, very small programs, and this has caused me a bit of a problem.
Ok, so the goal of this addition is:
To add the number of users currently online, in chatrooms, and print it on the chat signup page to entire users to join by showing how many people are active.
So, the users online status is determined in the mySQL database users - and the status is shown as 0 (default for offline) or > 0 for online users. What I need to do is have a query run, select all the rows where status > 0 and than on the signup page, print the total # of users.
So this is what I have (and it may not even be right, so please give me any pointers, so I can fix this):
$query = "SELECT `status` FROM `users` WHERE `status` != 0";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($totalusers = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo count($totalusers);
}
I've created a dummy table, with four statuses that are >0 and two that are <0. But obviously my code above is wrong because instead of displaying "4" it is displaying "1111".
I may not even be using the right function to total the # of rows in the database that are >0. So, this is where I am stuck for tonight, and need someone to help me solve this problem.
Thanks for any help,
Lindsey