0

I have a online list, I want it to remove the users off list after a certain amount of time they have been inactive.

How would I make the second query work with what im trying to do?

<?php
//On page load with a logged-in user
mysql_query("UPDATE `users` SET `last_activity` = NOW() WHERE `username` = '" . ($_SESSION['username']) . "'");

mysql_query("UPDATE `users` 
             SET `online` = 0 
             WHERE `last_activity` < NOW('+11 minutes') ");
?>  

Right now it, takes away everyone off the list no matter how much time their timestamp is.

1 Answer 1

2

You need to use date_sub:

DATE_SUB(NOW(),INTERVAL 11 MINUTE)

Sign up to request clarification or add additional context in comments.

3 Comments

Alright thanks im trying it now, gotta wait some time to see if it works :)
if you want to test it change MINUTE to SECOND
Works grea tthank you very much I've been dealing with this problem for hours XD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.