Php Pm系统收件箱/发件箱一起(facebook风格)

时间:2015-11-04 10:42:27

标签: php mysql message messaging

我尝试制作一个页面,显示每个用户的最新下午,例如在Facebook中,所有已发送和接收的消息都在同一页面中。

我不想拆分带有收到和发送标签的邮件页面。

我建立了这个查询但却陷入困境,无法继续下去。

SELECT pm_id,  message, unread, time_sent, from_id, to_id,
    (SELECT COUNT(DISTINCT from_id) FROM pm WHERE to_id = $_SESSION['user_id'] AND recipient_delete = "0") as pm_count
    FROM   (SELECT *
            FROM pm
            ORDER BY time_sent DESC) as temp
    WHERE (to_id = $_SESSION['user_id']   AND recipient_delete = "0")
    OR ( from_id = $_SESSION['user_id'] AND sender_delete = "0") 
    GROUP BY from_id, to_id
    ORDER BY time_sent desc

有了这个,我会在this image之类的用户之间收到重复的帖子。

0 个答案:

没有答案