KaiSheng Posted November 11, 2013 Share Posted November 11, 2013 (edited) 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. Edited November 11, 2013 by KaiSheng Quote Link to comment Share on other sites More sharing options...
requinix Posted November 11, 2013 Share Posted November 11, 2013 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. Quote Link to comment Share on other sites More sharing options...
KaiSheng Posted November 11, 2013 Author Share Posted November 11, 2013 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. Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted November 11, 2013 Solution Share Posted November 11, 2013 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. Quote Link to comment Share on other sites More sharing options...
KaiSheng Posted November 12, 2013 Author Share Posted November 12, 2013 okay got it. thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.