当输入新的sql条目时刷新html页面
所以我有一个外部脚本,有时会全天向sql数据库输入一些内容(通常每天大约3次,但可能每分钟更新一次)我需要找到一种方法来制作html页面(显示sql条目) ) 当添加新条目时自动刷新。对 PHP 和 SQL 有什么建议吗?我正在考虑 Ajax,但我很确定我需要进行整页刷新,因为它也会更新图像。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要一种方法让浏览器知道数据已更新。
最简单的方法是使用 ajax 调用来汇集服务器以检查是否已添加新数据。您可以使用 javascript 将其设置为每分钟或您想要的频率调用。一旦 ajax 调用显示新数据已加载,您就可以使用 javascript 刷新页面。
这种方法意味着您对服务器有很多调用,但它们很小,并且仅在需要时才会加载完整数据。
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.