Danny620 Posted July 25, 2009 Share Posted July 25, 2009 say i clicked a buttions that says "in 30mins time your profile will be updated" then it counts down from that time i pressed it and when its counted down it runs what it needs to run. how do you do this? Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/ Share on other sites More sharing options...
.josh Posted July 25, 2009 Share Posted July 25, 2009 okay so instead of making 500 threads that all seem to be related, how about explaining your overall goal here... Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-882892 Share on other sites More sharing options...
Danny620 Posted July 26, 2009 Author Share Posted July 26, 2009 OK heres what i am planing to do i want to build a game where the user logins and he has is own town thing then he clicks on the HQ and there he can upgrade his buildings by clicking on like "upgrade to level x" then this would start the contruction that's where the countdown comes in say he upgrades to level 2 hes building takes 34Min's to construct that's where i want it to count down 34Min's then run the script that updates the db to say hes level 2. Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883148 Share on other sites More sharing options...
gevans Posted July 26, 2009 Share Posted July 26, 2009 Why don't you have a table in your database called construction. When a user clicks 'upgrade to level x' a row is added to the table with the end time (current timestamp plus {60*34} for 34 mins), the users id and a reference to the building. On page load check that table for results, if it's empty nothing is being built, if it has results check the end time against the current time. If it has passed delete the row from the construction table and update the necessary hq level. Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883269 Share on other sites More sharing options...
vineld Posted July 26, 2009 Share Posted July 26, 2009 I think maybe it would be a good idea to build something less complex than an antire game until you get a good grip of the language. Chances are you will need to go back and correct A LOT of code otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883279 Share on other sites More sharing options...
Danny620 Posted July 26, 2009 Author Share Posted July 26, 2009 thats what i had in mined e.g set a future date and time in db and then everytime the page is reloaded check to see if the time now is greater then the one in db if it is update level to 2. does that sound good to u. Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883294 Share on other sites More sharing options...
Danny620 Posted July 26, 2009 Author Share Posted July 26, 2009 but does the date(); function go off the users time and date of so how do i make it go off the servers date beacuse the user could change his date and time to 30mins in frount then he would not have to wait am i right? Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883296 Share on other sites More sharing options...
vineld Posted July 26, 2009 Share Posted July 26, 2009 Server side scripts can only obtain what is at the server unless the client submits data. Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883306 Share on other sites More sharing options...
Danny620 Posted July 26, 2009 Author Share Posted July 26, 2009 ye i want it when the user clicks level 2 get server date and time Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883317 Share on other sites More sharing options...
vineld Posted July 26, 2009 Share Posted July 26, 2009 Then have a look at date() and time(). Time() is more efficient so if you don't need any particular format for some reason, use the timestamp instead. Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883325 Share on other sites More sharing options...
Danny620 Posted July 26, 2009 Author Share Posted July 26, 2009 ha ha lol i no why i was so confused lol it was because of my localhost test server when i changed the time on windows it was obusly going to change the time of my Apache server that's why i came up with that idea above Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883422 Share on other sites More sharing options...
.josh Posted July 26, 2009 Share Posted July 26, 2009 Quote Link to comment https://forums.phpfreaks.com/topic/167434-solved-php-how-to-add-a-countdown-script-till-something-is-updated/#findComment-883427 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.