输入新的sql条目时刷新html页面 [英] refresh html page when a new sql entry has been inputted

查看:77
本文介绍了输入新的sql条目时刷新html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个外部脚本,有时有时会整天(通常每天大约3次,但可能每分钟更新一次)将某些内容输入到sql数据库中,所以我需要找到一种方法来制作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.

推荐答案

您需要一种让浏览器知道数据已更新的方法。

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

最简单的方法是进行ajax调用,将服务器池化,以检查是否已添加新数据。您可以使用javascript将此名称设置为每分钟或经常调用一次。一旦ajax调用显示已加载了新数据,则可以使用javascript刷新页面。

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.

这篇关于输入新的sql条目时刷新html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆