On the main page I do an update on the user record. I save the current datetime off the user who is logged in. (ea. the username in the cookie)
I also do an select on the userlist where all records are selected where the datetime is within the last half hour
beneath here both queries are mentioned and they are both on the main page
$hourdiff = "2";
$timeadjust = ($hourdiff *60 * 60);
$datum = gmdate("Y-m-d G:i:s",time() + $timeadjust);
$query="UPDATE lowlandusers SET llulastonforum='$datum' WHERE lluid='$id'";
$rs3=mysql_query($query,$conn);
function Opforum($conn){
$hourdiff = "2";
$houradjust = ($hourdiff *60 * 60);
$minutediff = "30";
$minuteadjust = ($minutediff * 60);
$datum = gmdate("Y-m-d G:i:s",time() - $minuteadjust + $houradjust);
$query="SELECT lluname,date_format(llulastonforum,'%Y-%m-%d %H:%i:%s') as datumlaatst FROM lowlandusers order by llulastonforum desc";
$rs2=mysql_query($query,$conn);
$list = mysql_num_rows($rs2);
while($i < $list)
{
$row = mysql_fetch_array($rs2);
$naamuser=$row["lluname"];
$datumlaatst=$row["datumlaatst"];
if ($datumlaatst > $datum) {
$test=strtotime($datumlaatst);
$test2=strtotime($datum);
$test3=$test - $test2;
$tijd=$minutediff - ($test-$test2)/60;
if ($tijd >="0" AND $tijd < "2"

{$kleurcode="33ff66";}
if ($tijd >=2 AND $tijd < 5) {$kleurcode="33cc66";}
if ($tijd >=5 AND $tijd < 10) {$kleurcode="333366";}
if ($tijd >=10 AND $tijd < 20) {$kleurcode="006666";}
if ($tijd >=20 AND $tijd < 30) {$kleurcode="003300";}
print "<font color=$kleurcode>$naamuser </font>";
}
$i++;
}
}