nightkarnation Posted July 11, 2011 Share Posted July 11, 2011 Hey Guys, I need some help and/or suggestions on how to apply the following: Simple Example Code: $result = mysql_query("SELECT Last_B_Time FROM MAIN WHERE Id = '$id'"); $cant = 0; while($row=mysql_fetch_array($result)) { echo "Last_B_Time$cant=$row[Last_B_Time]&"; $cant++; } I want this simple code/query and echo to be executed every second (not once), directly when test.php is opened. What is the best way to do this? Using a timer? Thanks a lot in advance! Quote Link to comment https://forums.phpfreaks.com/topic/241738-same-query-every-second-not-once/ Share on other sites More sharing options...
freelance84 Posted July 11, 2011 Share Posted July 11, 2011 You want this script to run once a second when the page is loaded? Why? Quote Link to comment https://forums.phpfreaks.com/topic/241738-same-query-every-second-not-once/#findComment-1241553 Share on other sites More sharing options...
AyKay47 Posted July 11, 2011 Share Posted July 11, 2011 I am not sure why you would want to do this, and your memory/server won't be thanking you... Quote Link to comment https://forums.phpfreaks.com/topic/241738-same-query-every-second-not-once/#findComment-1241556 Share on other sites More sharing options...
nightkarnation Posted July 11, 2011 Author Share Posted July 11, 2011 I have a dedicated server. I need to do this, to retrieve the server date every second. I know this would be easily fixed performing a calculation with just retrieving once the server date but I also need to know each second if there has been a new bid for any auction (its an auction site) Any suggestions? Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/241738-same-query-every-second-not-once/#findComment-1241561 Share on other sites More sharing options...
AyKay47 Posted July 11, 2011 Share Posted July 11, 2011 i assume that when someone bids for an item, a form will be submitted which will trigger code...right? So wouldn't you be "notified" then? Quote Link to comment https://forums.phpfreaks.com/topic/241738-same-query-every-second-not-once/#findComment-1241607 Share on other sites More sharing options...
nightkarnation Posted July 12, 2011 Author Share Posted July 12, 2011 The thing is that I need to do some automatic special features on different seconds...and I need to retrieve every single second in order to send these special features (from an outside application running every second through php). Quote Link to comment https://forums.phpfreaks.com/topic/241738-same-query-every-second-not-once/#findComment-1241879 Share on other sites More sharing options...
freelance84 Posted July 12, 2011 Share Posted July 12, 2011 Well, the php script will only run (i think) with action from an outside source. If you are wanting to send once a second a bit of data from the client to the server and back to the client... AJAX? But then what if the connection slows at any point and the data transfer is 3 seconds? That would screw your script up. What are the special functions? Do they need to be done by the server? Would a js function suffice? Quote Link to comment https://forums.phpfreaks.com/topic/241738-same-query-every-second-not-once/#findComment-1241908 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.