I've created a notifications system / alert system for my website where as an admin i can send notifications to my users.
When i had started it, i created a column called comment_seen and when I inserted a new comment / alert and it was 0, i'd use ajax / jquery to check and then it would notify the users they had a new notification, when they click on it, it would then change the '0' to a '1', i then noticed that if one user looks at it, globally no one else would then know they have a notification as i was just using one table.
I then created a new table called alertsseen, here when a user views their notifications it now adds to the table the alertID and the userID.
My code at the moment that checks for new notifications is
$status_query = "SELECT * FROM comments WHERE comment_status=0";
$result_query = mysqli_query($con, $status_query);
$count = mysqli_num_rows($result_query);
$data = array(
'notification' => $output,
'unseen_notification' => $count
);
I am wondering if there is a way / query to first check the comments table and then check the alertseen table, and if the id of the comment / alert is not in the alertsseen table for that user, it will show it as a new notification in $count.
Any help appreciated, hopefully this made sense.