custom php forum - showing new/unread posts

后端 未结 5 2248
臣服心动
臣服心动 2021-02-14 23:26

I have written myself a custom forum script using php. I decided against using phpbb and others as I wanted 100% flexibility with what I was doing.

I\'ve hit a problem

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-15 00:11

    My approach would be to save the last post id of each topic a specific user has seen in the database:

    user_id   topic_id   post_id
    1         2          3
    

    So, here you know that user 1 visited the third post in the second topic, but didn't look at the first topic at all.

    To check if the user has new/unread topics you can first check for topic_id's which are not in this table for that user. To check if known topics have new messages you can compare the post_id with the last post_id of each topic. If they are not equal, there are new messages.

提交回复
热议问题