refresh html page when a new sql entry has been inputted

╄→гoц情女王★ 提交于 2020-01-05 08:43:26

问题


So I have an external script that will sometimes input something into a sql database throughout the day (usually about 3 times a day, but could potentially update ever minute) I need to find a way to make the html page (that displays the sql entries) refresh automatically when there is a new entry that's added. Any suggestions for PHP and SQL? I was thinking Ajax, but I'm pretty sure I will need to do a full page refresh, because it will update images too.


回答1:


You need a way to let the browser know that the data has been updated.

The easiest way would be to have an ajax call that pools the server to check if new data has been added. You can use javascript to set this to be called every minute or however often you want. Once the ajax call shows that new data has been loaded, then you can use javascript to refresh the page.

This approach will mean you have a lot of calls to your server, but they will be small and the full data will only be loaded when needed.



来源:https://stackoverflow.com/questions/3972065/refresh-html-page-when-a-new-sql-entry-has-been-inputted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!