I've got 1 function that links @ symbols like Twitter. A excellent coder could probably whiz this in half hour to and hour. I'm gonna post the function in the window, because I don't want to get a newb that can't help. Read the function, if you know the solution, you can fix for money.
Bugs:
when and unknown name, that isn't in my DB is first it won't link even the known names, but it will if the known name comes first.
- if the DB connection fails, you’ll get an "cannot call method prepare() on null" error
- preg_replace() does work, but you never save the modified string but return the original string.
and you’ll also have a problem for similar usernames like "bob1" and "bob12" (the former tag also matches the latter)
I need this to nail the tagging dead on, as in any professional app like twitter. I know my code is sloppy, but hope you can fix this.
I'll require it working before money is release, so I'll want to test the function.
-----
public function handle_user_link($str){
if( preg_match_all('/([@]+\w+)/', $str, $matches)){
$matches = array_slice($matches, 0, 1);
for($i = 0; $i < count($matches); $i++)
{
// capture each tag
$tag = $matches[0][$i];
$name = ltrim($tag, '@');
try{
$db = new PDO($this->db['dsn'], $this->db['username'], $this->db['password'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}catch(\PDOException $e){}
$sqlName = $db->prepare("SELECT `username` FROM `users` WHERE `username` = ?");
$sqlName->execute(array($name));
$retrievedUser = $sqlName->fetch();
if(!empty($retrievedUser))
{
// tagged user exists.
$str = str_replace($tag, '<a href="[login to view URL]'.$name.'">' . $tag . '</a>' , $str);
}
}
}
return $str;
// End handle_user_link
}
5 years of Experience in PHP & WordPress & Custom Wordpress Templates, I've designed 200+ websites in wordpress. My wordpress skills will be very helpful for this project.
My recent works:
Wordpress Sites:
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
Online Store
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
Looking forward to have words with you.
Regards,
Sagar
Hello Sir/Madam, We have gone through the details you have provided and we have already worked on a similar project before and can deliver as u have mentioned and would be pleased to work on this with you to deliver the results that you have expected and we have already worked on a similar project before and can deliver as u have mentioned
We are sure you will not be disappointed if you give us this opportunity. Our team is experienced, creative & efficient enough to get your job done well. We have an impeccable record and all our clients enjoy working with us, we are sure that you will too, our prices are cheapest in market.
can u provide your email or sky-pe etc for further discussion about the project
I am ready to discuss with you
with best Regards
Hello
I have gone through your function code i can solve your code easily.
I have an 5 Years of experience in php programming
contact me for more information
thank you