Jump to content

Change status of user every 12:00am


KaiSheng

Recommended Posts

Hi all again!!

 

I will describe the game first.

According to my game, the person who plays the game will click on a "play" button, and status of the user will change from

available to played.

 

So, according to my query, i used "UPDATE users SET status ='played'"

I want to include something more.

anyone know how to include the query for the status to auto change (from played to available) every 12:00am (GMT+8 ) ?

 

Greatly appreciated for all comments.

:)

Link to comment
https://forums.phpfreaks.com/topic/283786-change-status-of-user-every-1200am/
Share on other sites

9/10 times if you want to update something in a database at a certain time, like for "resetting" something or updating a counter, there's a smarter way of going about it.

 

In this case the smarter way is just keeping track of the last time they played. If they played played today then they're not available, otherwise (if they played sometime before today) then they are available.

I do not know how to include the date they played. Because it's an update query, so the field must not be empty.

For example, using INSERT query, the field in database must be empty before this will work.

using UPDATE query, the field in database must not be empty.

I have no idea how this is gonna work using date timestamp, although I know this is an easier way.

It would be a timestamp instead of the status field. Update it to the current time when they play.

When you want to know who/whether someone is available, look at that timestamp: if it comes from today then they're not available, otherwise they are.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.