My question is, how do I count the rows in the database to ONLY count the ones set to 1? That way it can count how many people are currently online. I have one that counts the amount of registered users, but now I need it to count only the ones online. Here is the snipet of code that is supposed to count the rows that only have 1 listed.
Code: Select all
<?php
$sql = mysql_query("SELECT COUNT(1) AS online FROM players");
$num1 = mysql_fetch_array($sql);
$counts = $num1['online'];
echo ("$counts");
if($counts == 0)
{
echo "0";
}
?>