I am working on a "Who is Online" routine. I have an included routine on each page that inserts: the timestamp, the visitor's ip, the page they're on and if they're logged on, their username, otherwise "guest". Like this:
$insert = mysql_query("INSERT INTO $tbl_online (timestamp, ol_user, ip, file)
VALUES('$timestamp', '$ol_user','".$SERVER['REMOTE_ADDR']."','".$SERVER['PHP_SELF']."')")
Now I need to find out how many logged in users are online and display the data (except the timestamp) without repeating. This does not work:
$ol_val = mysql_query("SELECT DISTINCT ol_user, ip, file FROM $tbl_online WHERE ol_user != \"guest\"")
or die("error");
$ol_val_num = mysql_num_rows($ol_val);
This query repeats users that have been on different pages until the timestamp expires. I don't need to worry about the IP, but I need to select unique users & only one file for each.
Any ideas?