put this code in the home web page

 $timeoutsecs = 900;
 $timestamp = time();
 $caduc = $timestamp+$timeoutsecs;
 $conexion = @mysql_connect("localhost", "user", "password") or die ("No db
 mysql_select_db ("yourdb", $conexion);
 mysql_query("INSERT INTO uonline SET " . "caduc='$caduc'," .
"ip='$REMOTE_ADDR'," . "file='$PHP_SELF'");
 mysql_query("DELETE FROM uonline WHERE caduc<'$timestamp'");
 $result = mysql_query("SELECT DISTINCT ip FROM uonline");
 $conn = mysql_num_rows($result);
$dbdecnx = mysql_close ($conexion);
 if ($conn==1) {
  echo"<span class=\"textPequ\">$conn user online</span>";
  } else {
  echo"<span class=\"textPequ\">$conn users online</span>";

and create this table in you db to hold the necesary values

# Table structure for table 'uonline'

CREATE TABLE `uonline` (
  `caduc` int(15) NOT NULL default '0',
  `ip` varchar(40) NOT NULL default '',
  `file` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`caduc`),
  KEY `ip` (`ip`),
  KEY `file` (`file`)

this is working good in my site

Aniceto Lopez
download and spread our music

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to