Home > Article > Backend Development > Analysis of programming principles for group messaging within the site
2, a table that saves information sent to users. For example:
3, save the table of messages. For example:
When you want to send a message to the user: 1. Take out all uids from php_user_info (assuming they are stored in the array $array_uid), and then add php_message the ID of the message you want to send to the user, which is mid. Then, perform the insertion operation in a loop (insert uid and mid into php_user_message, id, ifShow and IfRead default to null, 0, 0 respectively). Notify users: The page calls ajax at regular intervals to check whether there is data with an ifShow value of 0 in the php_user_message of the user with your current uid. If it is 0, a pop-up window on the page will tell the user that the message has been received and change it to 1. User enters the message center: Check ifRead is 1, if not it is displayed as unread and when the user clicks on the message change ifRead to 1. The above introduces the design principle of realizing the backend administrator to send group messages in the site. I hope it can help everyone to have some guidance and help in writing similar PHP programs. |