Okay so I am using PHP MySQL .
I Want to Implement a Notification System For A Social Networking Site
Currently I have 2 Tables one For Posts containing columns
- id //id of the post
- body//
- status // For Notifications
- user_id// id of the user
Whenever a preson comments or likes a particular post, 1 New record is inserted in the Notification table.
Notification Table Has the following columns
- id// id of the notification
- src_id // id of the post on which the user commented
- type// like , comment etc
- user_id //id of the user
So what the problem is that I want to fetch data from notifications table for which the user needs to be notified.
For Example Mysql Query is
SELECT * FROM notifications WHERE src_id IN ("244","245","249") order by src_id
For example I have some data like this in the notifications table
id type user_id src_id
1 like 6 244
2 comment 4 244
3 like 1 249
4 comment 8 249
5 comment 9 245
6 comment 3 244
7 like 12 244
How Do i display it in php by grouping them by their src_id
So that I can generate something like this
4,3 commented on your post 244
12,6 liked your post 244
1 liked your post 249
8 commented on your post 249
where 4,3,12,6,1,8
are user_ids