View Full Version : Resolved Javascript Timer and Mysql?

10-16-2010, 02:35 AM
Is it possible to make a Javascript timer that deletes a row from a mysql database once it hits 0 and then starts the count back over to delete another row?

I've made a PM system with php and would like it to delete old messages every 30 days that way my members can have it set to delete messages automatically or do it them selves.

10-16-2010, 01:27 PM
Theoretically, it's possible. It's not possible using Javascript alone, but if you used "Ajax" you would be able to make a Javascript function that would, without reloading the page, run a PHP script on the server to do that.

However, why??

The much easier way to do this is to just add a mysql delete query every time you load the page-- delete messages more than 30 days old. That would do the same thing and be much easier. Since this is a long time, that's fine. Perhaps if you wanted to delete messages more than 30 seconds old you'd want to use Javascript, but I don't even see how the Javascript would be relevant-- would they remain on the page for more than 30 days?

10-16-2010, 05:08 PM
To be honest I wasn't thinking about adding a mysql delete to the page load..
i had been thinking about doing the timer thing for some time now..

Thanks for helping me with that problem..