i want to make a 'who's online' function in my website .. but i do not know how to make tat appear in my webpage... i have the script called 'online.php' but how do i put it so tat it automactically shows when users enter the site without having to click any link like "click here to show who's online'
heres my online.php script
<?php
function whos_online() {
global $REMOTE_ADDR;
mysql_connect("localhost","root","");
mysql_select_db("Login");
$exp = time() + 300; //300 seconds for 5 minutes
$time = time();
$query = "select * from latest where ip='$REMOTE_ADDR'";
$result = mysql_query($query);
if(mysql_num_rows($result) == 1) {
$query = "update latest set time='$exp' where ip='$REMOTE_ADDR'";
mysql_query($query);
}else{
$query = "insert into latest VALUES('$REMOTE_ADDR','$exp')";
mysql_query($query);
}
//delete IP's that have expired...
$query = "delete from latest where $time > time";
mysql_query($query);
$uonline = mysql_num_rows(mysql_query("select * from latest"));
//print the variable on our page!
print($uonline);
}
whos_online();
print(" users online in the last 5 minutes");
?>
is it i paste this code into the html ? i tried but it doesnt work....
please help me~ im a newbie....