2016-09-08 37 views
-5

这是我Home.Php,我需要显示实时通知,数据库我如何能实现实时通知在我的PHP页面

<html> 
<body> 
<label>Notifications <?php echo "(".$notification.")"; ?>)</label> 
//$notification Contain no. of Notifications From Database 
</body> 
</html> 
+0

AJAX和setInterval将让你中途有。为了接近真正的实时,你可能不得不看看websocket。 –

+0

哪个更安全? – Krishnan

+0

目前我正在使用@Node Js。在这里我有另一个问题。我需要执行如下查询: - select * from tb_users where user_id =“来自Php Session的值”。我需要从php Session获取User_id来执行查询。我该怎么做 ? :( – Krishnan

回答

0

您需要使用web socket用于实时通知。您可以尝试Ratchetsocket.io

+0

什么是使用网络套接字做它的第一步? – Krishnan

+0

@Krishnan学习如何使用网络套接字 – Epodax

+0

谢谢老板!!! – Krishnan

0

在这里它的例子

Real time notifications with PHP

+0

目前我正在使用@Node Js。在这里我有另一个问题。我需要执行一个查询,如: - select * from tb_users where user_id =“value from Php Session”。我需要从php Session获取User_id执行查询,我该怎么做?:( – Krishnan