I'm building a simple web app with PHP and Mysql. One of it's features is a page where all of the users can exchange messages with a textarea inside a form.
On the side of the textarea, i have a div with the pictures of all registed users. When writing a message, you can click on one the users' image and the name of the user will be written in the textarea.
How can i do a "tag" system in PHP so that when a user uses this feature and "tags" someone in a message, it will look for that name in a mySql table and then send a notification for a user?
I'm not asking for an answer with all the specific code to achieve this, just logic guidelines on how to do this. Thanks in advance!!
I would create a new database table of tags/notifications with at a minimum the User ID of the recipient, message, sent timestamp and read timestamp.
Have your script check this table and show notifications matching that user ID with no read timestamp. Once the user clicks the notification, you can insert the read timestamp in to the row to hide it.
To keep the database tidy, you could create an extra script perhaps a cron to clear all read notifications after a week. :)