Jump to content

PHP SQL @Tags


ibz786

Recommended Posts

Hi guys, i have not started this as of yet, however i will be given a project to make a micro-blogging website similar to that of Twitter or Facebook but obviously on a much smaller scale

 

I have been searching on google however i have not found anything. Maybe i haven't been using the right words in my query, not sure :-/

 

I have been trying to do some research, however i can't seem to find how to incorporate @ tags found in Twitter / Facebook.

e.g. If i want to tag a person in a Status Update:

Hey @John Smith, Football in the park at 3pm?

 

If anyone is able to help i would be grateful

 

Thank You 

Link to comment
Share on other sites

You store the entered text in your database. And when you retrieve it, you resolve any @Username text to a link. Something like:

 

// untested.
if (preg_match('~@([^\s]+)~', $row['input'], $matches)) {
    if (username_exists($matches[1])) {
        $row['input'] = str_replace($matches[0], '<a href="' . username_link($matches[1]) . '">@' . $matches[1] . '</a>', $row['input']);
    }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.