How to make notification to group users with read/unread flag?

Posted by user2335065 on Stack Overflow See other posts from Stack Overflow or by user2335065
Published on 2013-11-13T09:15:07Z Indexed on 2013/11/13 9:53 UTC
Read the original article Hit count: 223

I am making a notification system so that when users in a group perform an action, it will notify all the other users in the group. I want the notification to be marked "read" or "unread" for each user of the group. With that, I can easily retreive any unread notification for a user and display it. I am think about creating a notification table that have the following fields.

+----------------------+
| notification         |
+----------------------+
| id                   |
| userid               |
| content              |
| status (read/unread) |
| time                 |
+----------------------+

My question is:

  1. Whether it is the correct way of making the system? As it means that when there is 1,000 users in a group, then I have to insert 1,000 rows to the table. If not, what is the better way of doing this?
  2. If it is the way to do this, how can I write the php/mysql codes to do the looping of inserting the rows?

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql