Jeya Sri R Posted August 26, 2012 Share Posted August 26, 2012 Hi there, Am doing a project using PHP and Mysql in which am supposed to alter table values over time .On specifying an end value and time limit it should change gradually. Eg: My table contains 2 columns-> Name and value. My initial value is 0. On specifying 3 hrs and 300, the value from 0 should raise evenly to 300 at the rate of value+8.33 every 5 minutes. First of all I just want to know is there any possibility for this in MySql functions and procedures itself. If not, and it requires PHP server-side scripts , can you please give me a start? Thanks in advance.. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 26, 2012 Share Posted August 26, 2012 Sounds like you'll want to set up a cron job. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 26, 2012 Share Posted August 26, 2012 Why are you continuously updating the table, and not just calculating the correct new value on retrieval? Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted August 26, 2012 Share Posted August 26, 2012 I agree with Jesi about a cron job, but....check this out: http://stackoverflow.com/questions/6327155/how-to-increase-a-field-value-of-mysql-table-every-some-minutes-automatically Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 26, 2012 Share Posted August 26, 2012 Why are you continuously updating the table, and not just calculating the correct new value on retrieval? ^^ This is the better solution, IMO. Instead of just setting the time period (3 hours) and end value (300) you would also set the start time. You can then calculate the appropriate value in the SQL query or in PHP after retrieving the record. Quote Link to comment Share on other sites More sharing options...
Jeya Sri R Posted August 26, 2012 Author Share Posted August 26, 2012 @all Thank you for the quick response people.. I came up with the idea of updating the values using event scheduler in mysql.. My prob now is i created the event successfully but it is turned off currently how can I turn it on? Quote Link to comment Share on other sites More sharing options...
Jeya Sri R Posted August 26, 2012 Author Share Posted August 26, 2012 Figured it out... thank u people.. U made my day.. Actualluy i tried to ploy graph using the altering values in php.. added auto refresh to the page now it looks great and fine.. Thank you one and all for the quick assistance.. :) Thank you PHP freaks Quote Link to comment Share on other sites More sharing options...
Monkuar Posted August 26, 2012 Share Posted August 26, 2012 Should't you be using long-polling or websockets? 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.