Jump to content

Search Box


Orionsbelter

Recommended Posts

Hi

 

Yes, a like. However you might want to search for items the both start with what is typed and contain what is typed (ie, put the ones it starts with first).

 

Something like:-

 

SELECT phrase, "Begins" AS fred FROM some_table WHERE phrase like "searchstring%"

UNION

SELECT phrase, "Contains" AS fred FROM some_table WHERE phrase like "%_searchstring%"

ORDER BY fred

 

All the best

 

Keith

 

Link to comment
https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787770
Share on other sites

Hi

 

Do you mean if you have a search table containing all the possible phrases? Possible (and how the search works for single words in some forum software), but likely to mean a massive table.

 

For example say you had a phrase "she sells sea shells" and wanted a list of all the possible phrases in that to search. Just that simple 4 word phrase would give you:-

 

she

she sells

she sells sea

she sells sea shells

sells

sells sea

sells sea shells

sea

sea shells

shells

 

The number of possible phrases would rapidly massively increase.

 

All the best

 

Keith

Link to comment
https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787783
Share on other sites

Hi

 

There is an algorithm called Soundex to match up words phonetically, although it is meant to be used with names (not sure it would work as well with normal words). Think the word equivalent is called Metaphone.

 

Probably best to have Google for those. There is a php function to calculate the metaphone.

 

All the best

 

Keith

Link to comment
https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787804
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.