virtuexru Posted March 24, 2009 Share Posted March 24, 2009 Like say I want to update a page that has a countdown on it for a number... The max for that number is 800 for instance.. I set that to be the maximum, then if the number on the page is less than that, I can add 100 every 30 minutes until it is equal to or greater than 800. How would I go about doing this in PHP without having to manage the page after I set the initial maximum? Link to comment https://forums.phpfreaks.com/topic/150964-can-i-set-a-session-on-a-page/ Share on other sites More sharing options...
POG1 Posted March 24, 2009 Share Posted March 24, 2009 I don;t know exactly what you are asking but I cooked something up quickly. session_start(); if(isset($_SESSION['number']) { // do some checks and do other things $thirtyMins = 60*30; if(isset($_SESSION['last']) AND time() > ($_SESSION['last'] + $thirtyMins)) { // update the last and number sessions } else { // no last done set the last session and do the first action to the number } } else { // no session and do something else } Link to comment https://forums.phpfreaks.com/topic/150964-can-i-set-a-session-on-a-page/#findComment-793132 Share on other sites More sharing options...
virtuexru Posted March 24, 2009 Author Share Posted March 24, 2009 But I need to run the script every 30 minutes or no? Link to comment https://forums.phpfreaks.com/topic/150964-can-i-set-a-session-on-a-page/#findComment-793169 Share on other sites More sharing options...
WolfRage Posted March 24, 2009 Share Posted March 24, 2009 First why are you doing this? Second you are not explianing this very well, so the answers (output) you are going to get are just as sketchy as the input you have given. Third are you looking for cron jobs or what? Link to comment https://forums.phpfreaks.com/topic/150964-can-i-set-a-session-on-a-page/#findComment-793171 Share on other sites More sharing options...
virtuexru Posted March 24, 2009 Author Share Posted March 24, 2009 OK.. basically I'm doing a math project in PHP for a friend. He puts in an initial number into a MySQL database.. say 100. I need to run a script that when I enter a maximum say 1000, the page showing the number will go up by 50 every 30 minutes. Link to comment https://forums.phpfreaks.com/topic/150964-can-i-set-a-session-on-a-page/#findComment-793190 Share on other sites More sharing options...
WolfRage Posted March 24, 2009 Share Posted March 24, 2009 OK then use a session like POG1 said and use AJAX or javascript or even a meta redirect to refresh the page at set intervals. Link to comment https://forums.phpfreaks.com/topic/150964-can-i-set-a-session-on-a-page/#findComment-793203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.