Ordering results form a DB on no. of words found

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

Ordering results form a DB on no. of words found

Post by Calimero »

Problem:
User inputs several words, but results are maybe with all of them or with less words that matched fields in the database...

What is the CODE for ordering the results based on how many words from the textfield-input have been found = as a the criteria

Is this done trough MySQL or PHP?

Thanks ahead.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

If you use a mysql fulltext search then you can order the results by 'relevance'. That's not the actual number of words found but how relevant each of the results are using the search words given.
Post Reply