php - Waiting x seconds before checking a row in mysql -
I want to create a website MySQL query after a few seconds, in which the website user has taken action on my website. I think I can do it with php sleep, but I do not know it's the best way to do this. What are the options to do this? Thank you for your reply. Edit:
The idea is: I have a lobby where the registered users can join the website (when they are included in a mysql query, the SQL line, set They are connected to the lobby number x, and on slot X, but they are not connected to the server). When they join the lobby, I want to give them X time (say 5 minutes) to join Counter-Strike source server (this update updates the user row setting, which they connect to the server). But, I want to kick them in the lobby (this is just updating their row in the mysql database), if they are not included in the server in those 5 minutes, I have coded it all except the 5-minute wait part Have found and check whether they are connected.
The code is:
$ PlayerSlot = mysql_real_escape_string ($ _ POST ['plain']); $ SID = mysql_real_escape_string ($ _ POST ['jsID']); // Check if the real player is already in another lobby $ query = sprintf (select from "playern`` where` websiteUsers` select 'userID` ='% s', mysql_real_escape_string ($ _ session ['userID' ])); $ Result = mysql_query ($ query, $ con) or die ("Error checking user status:" .mysql_error ()); $ Line = mysql_fetch_row ($ result); $ PlayerPlaying = $ line [0]; // Check that slot is free $ query = "SELECT" "$ PlayerSlot". "From serverplayer"; $ Result = mysql_query ($ query, $ conn); $ PlayerSlotFree = mysql_fetch_row ($ result); If ($ playerPlaying == zero & amp; $ PlayerSlotFree [0] == zero) {$ query = '.. $ PlayerSlot ",` servern` = '"" update `` playern` = SET WebsiteUsers`' ' $ SID '' WHERE 'userID` =' ". $ _ Session ['user id']. "'"; $ Result = mysql_query ($ query, $ con) or die (mysql_error ()); $ Query = "update`` ServerPlayers`SET "$ PlayerSlot" `= '" $ _ session. ['UserID']. "', Where` serverID` =' "$ sid .. "'" .. $ Result = mysql_query ($ query, $ con) or die (mysql_error ()); // update existing players $ query = "update 'server' set 'serverplayer' = serverplayer + 1 where 'server id` ='". $ SID. "'"; $ Result = mysql_query ($ query, $ con) or die (mysql_error ()); // TO-DO Wait 5 minutes here and do another query}
Use SetTimeout () in javascript // Wait for 3 seconds, then execute setTimeout (function () {// your action}, 3000 ); // Every 3 seconds execute set interval (function () {// your action}, 3000);
Comments
Post a Comment