Searching by words
Posted: Sat Jan 13, 2007 4:23 pm
I have created a web-site with a very simple search function, currently it looks like this:
However if you search for "hat" you will get hits on "that", "chat", "phat" etc, whereas I would like it to only hit on "hat". By this i mean that "hat", " hat ", "HaT", "hat;", would all be deemed as a result.
Now before we go any further, I would like to point ouy that I have searched these forums for answers but still have problems
First off I tried using this method:
This produced the same search results as before, then I tried using:
However this resulted in 0 results no matter what string I searched for.
So basically, I would like some help in resolving my problems or any advice as to other methods by which I can achieve my goal. I will explain further if anything is unclear.
Thanks
EDIT:
Sorry if this is in the wrong forum, I was unsure where to stick it.
Code: Select all
$sql = "SELECT * FROM table WHERE col1 LIKE \"%$searchterms%\" OR shortdesc LIKE \"%$searchterms%\" OR longdesc LIKE \"%$searchterms%\"";Now before we go any further, I would like to point ouy that I have searched these forums for answers but still have problems
First off I tried using this method:
Code: Select all
$sql = "SELECT * FROM table WHERE col1 LIKE \"%{$searchterms}%\" OR shortdesc LIKE \"%{$searchterms}%\" OR longdesc LIKE \"%{$searchterms}%\"";Code: Select all
$sql = "SELECT * FROM table WHERE col1 RLIKE [[:<:]]".$searchterms."[[:>:]] OR shortdesc RLIKE [[:<:]]".$searchterms."[[:>:]] OR longdesc RLIKE [[:<:]]".$searchterms."[[:>:]]";So basically, I would like some help in resolving my problems or any advice as to other methods by which I can achieve my goal. I will explain further if anything is unclear.
Thanks
EDIT:
Sorry if this is in the wrong forum, I was unsure where to stick it.