I'm new to php. I want to execute mysql query periodically (say every 5 seconds) using script. Query can be anything (as for now such as getting all data one by one from databse or inserting data to database). How can I do this? I've been through some examples but as I'm new to php, I'm not getting.
you can do this using event or cron job created on server
using event
DELIMITER $$
ALTER EVENT `ev_myevent` ON SCHEDULE EVERY 5 SECOND STARTS '2013-10-23 11:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN
// your code here
END$$
DELIMITER ;
using cronjob
check this link
1 Cronjob execute PHP script
If you want to update content in your site every 5 seconds and update database then you do it by ajax calling. Other then if you want to update database periodically then use cron.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.