Simple MySQL Search

Soldato
Joined
2 May 2004
Posts
19,950
Hi,

I've been wanting to make a good 'search engine' (no, I'm not gonna rival google, just want to search over my site :p).

I've been using FULLTEXT with:

SELECT * FROM tablename WHERE MATCH (fieldname) AGAINST ('$search')

Then I print the results below as usual.

This works perfectly for entering full words, but it's rubbish, especially for me, when everything's one word... meaning users have to enter the exact entry name to find it.

How can I make a 'search engine' that's a bit more advanced but still simple please?

I'd like to try keep to the simpleness of query & print results if possible.

Thanks,
Craig.
 
Tried was was suggested above and none of it really worked.

Could it be that fulltext only matches full words? Each entry in the field I'm wanting to search is one word meaning the user needs to enter the full string to find it?

The search works fine when I enter the full string, but when I try search using part of the string it doesn't find anything.
 
Last edited:
Just thought i'd let you guys know, I managed to sort it using % e.g.

Code:
$sql = "SELECT * FROM files WHERE realname LIKE %$userQuery%";

Works perfectly now, I can enter part of a full string and it'll find it :)

Craig.
 
robmiller said:
FULLTEXT is looooads better, try and get that working :)

Got fulltext working, but when I search with that I only get results if I enter the full string... all user entries are one string in this application so I need to be able to search part-string.
 
Back
Top Bottom