Forum Moderators: coopster

Message Too Old, No Replies

pulling out related information with PHP from a MySQL database table

         

Kavkan

7:03 pm on Jul 29, 2009 (gmt 0)

10+ Year Member



I'm working on a site that displays various articles.. once a specific article is displayed, other articles with similar content would be suggested for that user to read. I'm trying to wrap my mind around the logic of this.. but I'm not really sure what would be the best approach to go about it.

Do I use user submitted tags? Or, would it be better to use a MySQL search script by querying the title of the article that's currently displayed and having the results show up beside it?

Any suggestions? Could anyone recommend some tutorials related to developing something like this?

mvaz

12:27 pm on Jul 30, 2009 (gmt 0)

10+ Year Member



One suggestion would be to categorise the articles, and when an article displayed, have other latest articles under the similar category be displayed.

Kavkan

12:57 pm on Jul 30, 2009 (gmt 0)

10+ Year Member



Thanks for the suggestion mvaz. :)

The articles would be user submitted.. so then I guess I'd have to give users the option to select a category that the article they write falls in. But, the thing is, I'd like to avoid that.. i.e. ideally, I'd be able to categorize the articles seemlesly by the text that they contain.

That's why I was thinking of possibly using the title of the article to search trhough other articles for similar terms and displaying the articles that contain some or all of the terms. Would this be a valid approach or is there a better way to go about it?

Kavkan

2:08 pm on Jul 30, 2009 (gmt 0)

10+ Year Member



So it seems I could use the similar_text PHP function..

<?php
similar_text("Hello World","Hello Peter",$percent);
echo $percent;
?>

So this would return the level of similarity btween the strings "Hello World" and "Hello Peter". But would I beable to use this to compare strings within a table field?

ie. could I do something like

<?php
similar_text(SELECT article1 FROM..,"SELECT articles to compare to FROM...,$percent);
echo $percent;
?>

I guess this would require me to loop through all other articles in the column and return them in order of similarity. But, somehow this seems a bit inefficient.. I mean, if there are thousands of articles that this would have to loop through. Any suggestions?