PHP PM system logic
I am coding PHP PM system right now. I am just looking for the logic behind it not th开发者_C百科e code. Everything goes good just with 1 problem.
You can imagine how things works;
- User A sends pm to User B (User A has this pm in his sent box)
- User B can see pm in inbox.
- User B can delete PM (user A still could see it in sent box)
- User A can delete PM in sent box (user B still could see it in inbox)
My logic got stuck after this part. How do I show a pm to User A (in inbox) which User A sent to User B and User B replied?
Thank you for your help and time in advance.
Separate out the tables.
- Message table
This is responsible for the message itself - MessageUser table
This is responsible for linking/associating messages with users. This can take on properties to flag if it's a "Sent" or "Received" message.
For better examples, check out phpBB's tables, specifically the phpbb_privmsgs and phpbb_privmsgs_to tables.
You could store the user ID of the sending and receiving user with the message and then check if either ID matches when retrieving messages.
精彩评论