Php/mysql: usersonline, how many people are on which page

Hey. I’m making the admin section for a site, and i want to be able to see how many people are on which page.

i have my database set up with the following fields: timestamp, FILE. member, and ip.

timestamp: time() at entry
FILE: file user is on
member: member’s id from $_SESSION[“uid”], if not a user, then 0
ip: ip

I came up with this as an attempt, but if a person goes to another page, it shows up as another person.

$pagesOn = mysql_query("SELECT DISTINCT FILE FROM usersonline ORDER BY timestamp;",$conn);
for($i = 0; $i <= mysql_num_rows($pagesOn)-1; $i++){
        $file = mysql_result($pagesOn,$i,"FILE");
        $int2++;
            $getNum = mysql_query("SELECT DISTINCT ip FROM usersonline WHERE FILE ='$file' ORDER BY timestamp;",$conn);
            echo substr($file,1)."(".mysql_num_rows($getNum).")";
            if($i<>mysql_num_rows($pagesOn)-1){echo ", ";}
        }

I’m still kinda a newb to php, so i still need some help :slight_smile:

_naaman