I’m attempting to program a text based online game using PHP and MYSQL, one of the pages will allow you to mine. This means the MYSQL will have a record of your mined resources and the remaining resources in the mine. On the page that controls the mining I would like a field with a live number showing how much has been mined and how much resources still remain. How do you think I could do this?
If I was currently mining at a given rate would the database need to be updated constantly to keep track of what remained? Or could it record the time it started mining and if mining is stopped then calculate the mined resources and update only then? If so how do I keep a live track of this on the page for the user to see? (after a nice dynamic look).
Maybe read the database when the page is loaded and then use javascript to update the page based on the rate and remaining resources it read from the database?
This may be a problem as say the mining has been going long enough to completely mine the resources in the mine but the database hasn’t been updated with this information. Or even if say the rate of mining is changed in the database but as the javascript is predicting current status from the initial database read it will not reflect this change.
Hope you guys know what I’m rambling on about, any help appreciated.
Thanks
If I was currently mining at a given rate would the database need to be updated constantly to keep track of what remained? Or could it record the time it started mining and if mining is stopped then calculate the mined resources and update only then? If so how do I keep a live track of this on the page for the user to see? (after a nice dynamic look).
Maybe read the database when the page is loaded and then use javascript to update the page based on the rate and remaining resources it read from the database?
This may be a problem as say the mining has been going long enough to completely mine the resources in the mine but the database hasn’t been updated with this information. Or even if say the rate of mining is changed in the database but as the javascript is predicting current status from the initial database read it will not reflect this change.
Hope you guys know what I’m rambling on about, any help appreciated.
Thanks
Comment