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
https://forums.phpfreaks.com/topic/251907-php-sql-tags/
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
https://forums.phpfreaks.com/topic/251907-php-sql-tags/#findComment-1291766
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.