PHP/MySQL comparing strings in table fields

Discussion in 'Web Design and Development' started by ivopld, Jul 30, 2009.

  1. ivopld macrumors newbie

    Joined:
    Jul 30, 2009
    #1
    Hi all,

    I'm working on an app that lets users post artilces on different topics.. what I'm trying to do is display articles that are related to the one that a user is currently reading.

    How would I go about comparing one article to another 1000+ plus articles, and then displaying the top 10 most similar articles on the same page as the one that is already open?

    Should I be using the PHP 'similar_text' function?

    So something like..
    PHP:
    <?php
    similar_text
    ("Hello World","Hello Peter",$percent);
    echo 
    $percent;
    ?> 
    So I guess I could query the current article in the place of "Hello World", and then somehow query and loop through the remaining 1000+ articles in the place of "Hello Peter". Does make sense? Is the a good way to go about his? Any suggestions?
     
  2. Cerebrus' Maw macrumors 6502

    Joined:
    Mar 9, 2008
    Location:
    Brisbane, Australia
    #2
    Rather then using the entire text of the article, you could allow users to also fill out a tags field. You'll get a few words (say, on average, 10) that are important to that article.
    You can then compare tags from different articles. Which would be much faster then comparing the entire text of the article, and would be more accurate, due to the use of key words.

    You could then employ more advanced search techniques, maybe employing a kind of Page Rank algorithm, or Semantic Indexing in the future, on the actual body of the article, and give it a weighting in ratio to the tags.
     

Share This Page