在数据库记录刷新页面变化 [英] Page refresh on record in database changing

查看:182
本文介绍了在数据库记录刷新页面变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,所以我遇到了一个小问题。

Okay so I'm running into a small problem.

Basicly我的整个网站的运行,那里有一个左,右菜单,不刷新。

Basicly my whole website runs through the AJAX system, content is loaded in the middle page, and theres a left and right menu which dont refresh.

目前我正在试图寻找一个PHP的>的Ajax功能刷新整个网站在柜面MySQL表一定的记录更改

Currently I'm trying to look for a PHP->Ajax feature that refreshes the whole website incase a certain record changes in the MYSQL table

好了,所以每个用户都有一个名为国家的记录,表示其账户的状态,这可以被任何人更改,例如帐户被枪杀和被人杀害。我如何使它所以它会检查什么状态,你有,如果从非标准的状态,它执行完整页面刷新的变化。

Okay so every user has a record called "State" which indicates the state of their account, this can be changed by anyone, for example the account gets shot and killed by someone. How do I make it so it checks what state you have and if it changes from the "standart" state that it performs a full page refresh.

我试图找到这个无处不在的答案,但一直没能想办法。

I tried to find an answer for this everywhere but haven't been able to figure something out.

-----编辑-----

-----Edit-----

好了,所以我也会通知,那种我知道如何执行整页刷新,我知道如何从MySQL数据库中检索数据,这是没问题的。

Okay so I'll also notify, I kind of know how to perform a full page refresh, and I know how to retrieve data from the mysql database, this isn't the problem.

我在它所有的用户帐户,为每一位用户记录一个表被称为国家的各位状态将是1,这意味着活着。当其0则意味着它是一个死帐。

I have a table with all the users accounts in it, one of the records for every user is called "State" everybodies state will be 1 which means alive. when its 0 it means its a dead account.

在我的网站的一部分,那里有一个自动刷新与总是从每5秒数据库获取数据,并检查您的网络,如果你有资金等还检查什么状态你。

On a part of my website theres an auto refresh with always fetches data from the database every 5 seconds, to check if your online if you have money etc. it also checks what state you have.

我想做的事情,唯一的事情是,当它看到你的状态为0,它会执行整页刷新,考虑状态0就意味着死亡,你应该会看到一个deathscreen,我希望它执行整页刷新使菜单的有dissapear。它具有重定向到deathpage。

the only thing I want to do, is that when it sees your state is 0, it performs a full page refresh, considering state 0 means death, you should be seeing a deathscreen, I want it to perform a full page refresh cause the menu's have to dissapear. and it has to redirect you to the deathpage.

推荐答案

您需要很长池/彗星 - 基本上你保持客户端和服务器,而当状态改变之间的开放连接,服务器发送响应客户端。

You need long pooling / comet - basically you keep open connection between the client and the server, and when the state is changed, the server sends the response to the client.

基本上,你会打开一个长池连接,发送用户ID。 服务器脚本接收用户标识,并且开始监视该用户更改。如果这样的改变被检测到,发送响应。

Basically, you'll open a long pooling connection, sending the userid. The server script receives the userid, and starts monitoring for changes for that user. If such change is detected, send the response.

如果性能的关注,你可以用旋风Web服务器。什么是好的呢,就是你可以从其他应用程序到Web服务器后,它可以检测出哪些客户是受了变化,并发送响应到客户端。

If performance is concern, you can use Tornado web server. What's nice about it, is that you can post from another application to the web server, and it can detect which client is affected by the change and send response to that client.

这篇关于在数据库记录刷新页面变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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