

$content = str_replace($match_search, $match_replace, $content)

$match_user =$DB->row("SELECT * FROM users WHERE user_id=?",array($match)) $mention_regex = //mention regrex to get all (preg_match_all($mention_regex, $content, $matches))

If any text matches with username, then it will replace the names with the clickable urls Preg_match_all regrex is used to search for any character in the given content and store them in $matches array.īelow function is used to parse the in the content and check the names with the database. OnDataRequest:function (mode, query, callback) PHP Function to extract the in the content Ajax call will trigger after you type followed by characters Please add the class name mention to any textarea to get feature īelow jQuery code is used to get users suggestion from the database via ajax call while typing in the textarea. To make textarea box grow automatically while typing, you have to use HTML Form In addition to jQuery, it also depends on underscore.js (1.2+), which is used to simplify the whole component. It is nothing but a jQuery extension, so it naturally requires jQuery version (1.6+). I have used ntionsInput plugin that allows you to someone in a textarea box like facebook or twitter. Here denotes the mention – where 4 is the user id mentioned by the user 1 jQuery Plugin to Implement Mention Style Autocomplete Input All the user’s post are stored in the post_text column of the posts table.
