PDA

View Full Version : php/mysql: usersonline, how many people are on which page...



FreakSheep
February 11th, 2006, 06:46 PM
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 :)

_naaman

FreakSheep
February 13th, 2006, 01:06 PM
anyone?

bwh2
February 13th, 2006, 02:12 PM
phpfreaks.com used to have a tutorial on this. poke around there and i'm sure you can find it.