I had a similar user login script, the way I kept the table small is with every user trigger, I deleted all rows where timestamp was smaller then the current timestamp minus my range
it was quite a while back ago, and I dont think it was very optimal but it worked
I've never seen executeQuery, only mysql_query to execute Mysql commands, but if it works then I just learned something..
I dont think you need to delete the rows if you dont want to , let the db handle the rows produce a different output on the row information rather then requiring the query to come back false to determine if a user is offline.
Meaning, rather then deleting the user from the log book, let the log expire. The next time the user comes on, update their record and they will look online again. That way you dont have to keep writing/erasing the same user