Search question - how to get specific

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
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Search question - how to get specific

Post by JPlush76 »

I have a search script on my site now using LIKE with wildcards on either side. The problem is that if someone searches on "APHS" which is a type of film, anything with the word photogrAPHS comes up too.

Obviously because the pattern matches. However if I take off the wildcards it wont find it because its not the first word of the string.

Anyone have anything thoughts on how to go about that? So that if you search on APHS is searches the whole field to see if there is a word match?

thanks!
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Is photographs the only word that is the problem? Is APHS allways uppercase, if so can you possibly check the case on any matches to verify that you have what you want.


Just some thoughts,
John M
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

no its not the only word that is the problem it was just an example.

aphs is not always capital, just another example.

lets say I have a sentence "kodak films are great dude"

customer searches on "kodak film"

I'd want that product to come up because it contains kodak and film. I'd like to match words from start to end, having the end a wildcard IE LIKE $word%

the problem with that is if I use like its only checking the first word. :(
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

check out http://www.mysql.com/doc/en/Regexp.html
maybe you like it ;)
but of course it slows down the query
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

lol yea I just found it volka.

it took me a while to find that stupid line :) thanks

products_name REGEXP '[[:<:]]$t' OR products_description REGEXP '[[:<:]]$t'
Post Reply