PDA

View Full Version : Order by matches


Jon W
10-04-2009, 02:01 AM
Hello, I've been working on a search page for my site for a little while now. I have it pretty much done the only thing that I haven't finish is getting it to display the results by ordering by the ones that it finds the most matches with.

So for example, say you have a few article on how to fix a Vista OS. And the search term was "How to turn off programs in start up in windows vista".. Well, there might be 50 rows in the database that matches Vista alone. It's not like we don't want to display them, but one row is going to have more matches to that search term that than the other are. What would be nice is to order the rows by the one that has the most matches.

Is this something that you can do with MYSQL or is it going to require a little bit of both PHP and MYSQL?


Thanks,
Jon W

Old Pedant
10-04-2009, 09:29 PM
Look into MySQL "full text" searches.

Here's a good place to start, but be sure you follow all the links there to the relevant manual sections before you try all his tricks:
http://dev.mysql.com/tech-resources/articles/full-text-revealed.html