PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
well i figured that the online list that i coded was flawed because it only shows how many people are online. not who is online. And i am trying to think of a way to make it like that.
<?
$limit_time = time() - 300; // 5 Minute time out. 60 * 5 = 300
$sql = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time AND member='n' GROUP BY ip_address") or die (mysql_error());
$sql_member = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time AND member='y' GROUP BY ip_address") or die (mysql_error());
$visits = mysql_num_rows($sql);
$members = mysql_num_rows($sql_member);
echo "Guests Online: $visits<br/>";
echo "Members Online: $members<br/>";
?>
which usually outputs
Guests Online: 7
Members Online: 2
DeathsMessenger wrote:I didn't know about that one thank you. but after reading some of the other topics in the forum i found that this would be way simpler.
It uses too much resourses which u don't use later. Another advice: try not to use "select *" when you dont need all of the fileds from a table - use select col1, col2,.... instead.
DeathsMessenger wrote:But i still cannot figure out how to make a query find all the accounts with only the online set to 1.
Still waiting you to answer my second question
There are 10 types of people in this world, those who understand binary and those who don't
Right now you have all the information you need to get what you want (based on your original post). Just read the query result into an array using something like mysql_fetch_array() then use the resultant array to list who is online.