People online list edit.
Posted: Thu Aug 02, 2007 11:36 am
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.
Here is the counter
And the script displays the results
which usually outputs
Guests Online: 7
Members Online: 2
how should i go about changing the out put to
Guests Online: 7
Members Online: DM, Javisen
Here is the counter
Code: Select all
<?php
if (! isset($_SESSION['online'])) {
@mysql_query("INSERT INTO ppl_online (session_id,activity,ip_address,refurl,user_agent) VALUES ('" .session_id(). "', now(), '{$_SERVER['REMOTE_ADDR']}', '{$_SERVER['HTTP_REFERER']}', '{$_SERVER['HTTP_USER_AGENT']}')");
$_SESSION['online'] = $online;
} else {
if (isset($_SESSION['first_name'])) {
@mysql_query("UPDATE ppl_online SET activity=now(),member='y' WHERE session_id='" .session_id(). "'");
}
}
if (isset($_SESSION['online'])) {
@mysql_query("UPDATE ppl_online SET activity=now() WHERE session_id='" .session_id(). "'");
}
if (date('H') == 00) { // 00-23 hours. or 'D' == 'Sun'
@mysql_query("TRUNCATE TABLE ppl_online"); // Deletes all records. Faster than DELETE.
}
?>Code: Select all
<?
$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
how should i go about changing the out put to
Guests Online: 7
Members Online: DM, Javisen