Hi,
I have a simple chat script that registers users that have posted a message within the last ten minutes. If they do not submit for longer than 10 minutes then they are removed from the online table.
The way i have done it at the moment is to select the minutes from a time field and compare it against the minutes of curtime.. but as you will be aware this doesnt always work. if the script is not refreshed within a certain time then the name is not deleted. resulting in a list of online users that aren't online...
I need a way of calling the time from the time field and comparing it against current time to see if its older than ten minutes...
heres my current code:
// deletes users from online table that havent posted in 10 minutes.
$online_query = "SELECT username, minute(lastpost), minute(curtime()) FROM online";
$online_result = mysql_query($online_query);
while($online_results = mysql_fetch_row($online_result))
{
$user = $online_results[0];
$time = $online_results[1];
$cur_time = $online_results[2];
if($cur_time - $time >= 10 or $cur_time - $time < 0)
{
$result = mysql_query("delete from online where username='$user'");
}
}
please help