Home >Backend Development >PHP Tutorial >Analysis of programming principles for group messaging within the site

Analysis of programming principles for group messaging within the site

WBOY
WBOYOriginal
2016-07-25 08:55:561060browse
  1. php_user_info
  2. -----------------------------
  3. uid username password
  4. User's id username password
  5. ---------- ---------
Copy code

2, a table that saves information sent to users. For example:

  1. php_user_message
  2. --------------------------------------------- -
  3. id uid mid ifShow ifRead
  4. Auto-increment id User's id (and) message id Whether the message has been displayed to the user Whether the user has read the message
Copy code

3, save the table of messages. For example:

  1. php_message
  2. ----------------
  3. mid title content
  4. Message id title content
Copy code

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.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn