Alright, here is what I want; I have a table column that records my topics. For example; Topic name: Digital point. now I want that whenever someone types digital point on a reply, it automatically creates a link to the topic named digital point. First of all, if a script for this exists, what is its name and secondly is it possible something like this?
i hope i understand what you want. but maybe your problem is simpler than what you expect. $url = "digital-point-topic.html";//you can pull this from any where such as your mysql table or wherever you have it $link = '<a href="'.$url.'">digital point</a>'; //when a comment is submitted, before storing it $comment = str_replace('digital point', $link , $comment); //now store your comment. PHP: hope you see the mechanism
first of all I wanna thank you for your concern =) This one is actually the most simple form of what I want. It will only convert digital point to a link, but what if I have 10 topic names? I want all of them to be linked whenever someone uses that names in the reply. That's my real problem I cannot find a solution.
I'm fairly new to this but wouldn't it be the same with multiple topics, just adding them in just like the code zeronese gave?
hmm actually this may work but not sure how will it work it a gigantic database; $url = this will provide the links; $wordtomakelink = mysql_query("SELECT*FROM table WHERE topicname = '$variable'") or die(); // to get topic names $link = <a href='$url'>$wordtomakelink</a>; $comment = str_replace('$wortomakelink', '$link', $comment); Yeah this might work but I am not sure if it will work with databases like 3 million rows. Besides, yeah it is actually an easy script but what was bothering me is I was trying to make an if statement that checks if the topic name exists within the comment, but I guess I don't need it. I'll give it a try and tell you whether it works or not. Thanks for your replies=)
3 million rows wow So if there is a topic named php-help, and somebody writes digitalpoint in any comment on this topic will it get linked to the digitalpoint topic.
If there is a topic named 'Box' and someone posts reply in topic 'Cube' with word 'Box', you want that the word 'Box' would be turned into a link? Do i understand your idea correctly?
Alright, here is another problem I faced while trying to figure out how to write the script. If I use str_replace before storing replies to database, topics created after the reply won't be counted. Check here and you'll understand better what I want exactly; http://en.wikipedia.org/wiki/Sarah_Palin