I have a question about the following PHP script - I got it off a web
site tutorial on how to count users logged into your site - my
question is the $PHP_SELF variable - it writes the name of the web
page to the 'file' field in the table - I don't understand why it is
doing that - I mean, isn't the SELECT DISTINCT statement only pulling
those records from that one web page? I guess I just don't follow what
it is doing with that SELECT DISTINCT statement???
$timeoutseconds = 300;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds ;
$php_SQL = "INSERT INTO online SET timestamp='$tim estamp',
ip='$REMOTE_ADD R', file='$PHP_SELF '";
$php_resultID = mysql_query($ph p_SQL, $php_linkID);
$php_SQL = "DELETE FROM online WHERE timestamp < $timeout";
$php_resultID = mysql_query($ph p_SQL, $php_linkID);
$php_SQL = "SELECT DISTINCT ip FROM online WHERE file = '$PHP_SELF'";
$php_resultID = mysql_query($ph p_SQL, $php_linkID);
$php_users_onli ne = mysql_num_rows( $php_resultID);
if ($php_users_onl ine == 1)
{
print "<BR>$php_users _online user is currently online";
}
else
{
print "<BR>$php_users _online users are currently online";
}
site tutorial on how to count users logged into your site - my
question is the $PHP_SELF variable - it writes the name of the web
page to the 'file' field in the table - I don't understand why it is
doing that - I mean, isn't the SELECT DISTINCT statement only pulling
those records from that one web page? I guess I just don't follow what
it is doing with that SELECT DISTINCT statement???
$timeoutseconds = 300;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds ;
$php_SQL = "INSERT INTO online SET timestamp='$tim estamp',
ip='$REMOTE_ADD R', file='$PHP_SELF '";
$php_resultID = mysql_query($ph p_SQL, $php_linkID);
$php_SQL = "DELETE FROM online WHERE timestamp < $timeout";
$php_resultID = mysql_query($ph p_SQL, $php_linkID);
$php_SQL = "SELECT DISTINCT ip FROM online WHERE file = '$PHP_SELF'";
$php_resultID = mysql_query($ph p_SQL, $php_linkID);
$php_users_onli ne = mysql_num_rows( $php_resultID);
if ($php_users_onl ine == 1)
{
print "<BR>$php_users _online user is currently online";
}
else
{
print "<BR>$php_users _online users are currently online";
}
Comment