healer healer - 6 months ago 33
Ajax Question

Notification with 3 specific recipients

I'm creating a notification with 3 specific receiver. My problem is when 1 receiver view the notification the viewed field will become 1 and when the other receiver log in and view all notification it wont display because its already mark as read.



You can create a new table notifications_seen with columns like id,user_id,notification_id. When you want to know if a user already have seen the notification, just query this table. When the result is 0 rows, you can display the notification.

$sql = "SELECT 1 FROM `notifications_seen` WHERE `user_id` = 1 AND `notification_id` = 13;
$result = $db->query($sql);
if($db->num($result) == 0)
  // add code to view notification
  // don't forget to to make an INSERT when the notification was seen