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

**URL:** <https://forum.kirupa.com/t/php-mysql-usersonline-how-many-people-are-on-which-page/178564>\
**Category:** Uncategorized\
**Created:** [February 11, 2006, 11:46pm UTC](https://forum.kirupa.com/t/php-mysql-usersonline-how-many-people-are-on-which-page/178564 "2006-02-11T23:46:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FreakSheep](https://avatars.discourse-cdn.com/v4/letter/f/d9b06d/32.png) [@FreakSheep](https://forum.kirupa.com/u/FreakSheep)\
**Post date:** [February 11, 2006, 11:46pm UTC](https://forum.kirupa.com/t/php-mysql-usersonline-how-many-people-are-on-which-page/178564/1 "2006-02-11T23:46:42Z")

</div>

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.

```php
$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 🙂

\_naaman
