I don't even know how to search the script in google lol

Discussion in 'PHP' started by Shaokan, Jul 3, 2009.

  1. #1
    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?
     
    Shaokan, Jul 3, 2009 IP
  2. zeronese

    zeronese Peon

    Messages:
    83
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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
     
    zeronese, Jul 3, 2009 IP
  3. Shaokan

    Shaokan Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    Shaokan, Jul 3, 2009 IP
  4. jimmyleem

    jimmyleem Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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?
     
    jimmyleem, Jul 3, 2009 IP
  5. Shaokan

    Shaokan Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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=)
     
    Shaokan, Jul 4, 2009 IP
  6. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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.
     
    wd_2k6, Jul 4, 2009 IP
  7. flakas123

    flakas123 Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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?
     
    flakas123, Jul 4, 2009 IP
  8. Shaokan

    Shaokan Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    yeah yeah, exactly, like the one in wikipedia.
     
    Shaokan, Jul 4, 2009 IP
  9. Shaokan

    Shaokan Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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
     
    Shaokan, Jul 4, 2009 IP
  10. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #10
    True maybe you could update it every time a new topic is created or something
     
    wd_2k6, Jul 4, 2009 IP