So I am trying to setup an online list for my website and I seem to be having a problem. I have done this before, but I have not php'd in about a year and need a little refreshing time to time.
At this point I am stuck trying to edit a time stamp to show that if a user has been online in the last ten minutes then show them online.
So this is what my script looks like. I'll put some comments into it and if there is anything you can think of that will help then please do so. Thanks.
<?php
include 'connect.php';
include 'header.php';
if(isset($_COOKIE['member_id'])){
$Time=date("H:i:s");
$Player=$_COOKIE['member_id'];
mysql_query("Update Users set Online='$Time' where ID='$Player'");
}
echo"<h1><u>Online</u></h1>";
echo"<table class=\"table\"><tr><td>Username</td><td>Level</td></tr>";
$TimeFrame=date("H:i:s");//using server time
$TimeFrame=$TimeFrame-600;//subtracting 600 seconds, aka 10 minutes
print $TimeFrame;//prints out a negative 3 digit number like \"-592\"
$On="SELECT * from Users where Online>='$TimeFrame'";
$On2=mysql_query($On) or die("Could not query players");
while($Online=mysql_fetch_array($On2))//shows all players online, even inactive
{
echo"<tr><td>$Online[Playername]</td><td>$Online[Level]</td></tr>";
}
echo"</table>";
?>
So anything commented on in this script is where there is a potential problem.