i want to show the notification of my posting.
but my script cann't working
i have 4 table - user, group, article, comment

user :
id_user username
1 | user1
2 | user2
3 | user3

group :
id_group name content
1 | Script
2 | Math

article :
id_news |id_group | title content
1 | 1 | PHP | how we can learn PHP?
2 | 2 | HTML | how we can learn html?
3 | 1 | PHPagain | how we can learn PHP again?

Comment
id_comment id_news comment
1 | 1 | in school we can learn PHP
2 | 1 | in my web we can learn PHP
3 | 2 | HTML is easy in w3schools
4 | 3 | in my web we can learn PHP again

Result :
Notification (3 comment)
1 Script - 2 comment (user1, user2)
2 Math - 1 comment (user3)

Sould i create new table? -table notification?
or only use query of my table?

Facebook-style notifications revolve around the concept of "following" a post, which is done automatically when a user either A) Created the post, B) Likes the post, or C) Comments on the post.

I'm sure there's a more efficient way to do this but the simplest I can think of is to create another column for each article named users_following or similar and store the user IDs of the user who posted the article and the users who have commented on it inside(Can use JSON, serialization, CSV). Then when a new comment is made, send a notification to everyone on the list. Notifications should be inserted into a new notifcations table, which can contain a "read" column, this way you can check if the user already has a notification about the target article and avoid spamming them with notifications.

so better if i create a notification table contain of read column and also the id of every table?

The notification table should hold the id of the item(say, article) in addition to the text notification (e.g. "Matt Parker has commented on XXXXX Article"). For user-friendliness you should add a "read" column that stores whether the notification has been viewed or not - Then when making more notifications, you only send them(insert into the table) if there isn't already an unread notification for the same time. Like say if I already have a pending(unread) notification for article #63371, you don't send me more notifications for that article until my last one is marked as read.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.