I have a table which has the following fields “backupID”, “title”, and “content”. I have made a search page where it searches in all three fields looking for the word being searched.
I have come to a few problems:
1) I have made it so if it finds the word it makes that specific word in bold and yellow. but the thing is if I search for the word “james” for example, and there is a “James” it will find it but it will not make it bold. because of ascii problems Im guessing so what can I do?
2) If I search for (example) “villa moda” it will find villa moda but if I search for “moda villa”, it will not find anything with villa moda. I did fix this in a really stupid way because i needed to get it running but can anyone tell me how to do it the right way?
what I have done:
[code=php]
SELECT * FROM backup WHERE name LIKE ‘%$word[0]%’ OR name LIKE ‘%$word[1]%’ OR name LIKE ‘%$word[2]%’ OR name LIKE ‘%$word[3]%’ OR content LIKE ‘%$word[0]%’ OR content LIKE ‘%$word[1]%’ OR content LIKE ‘%$word[2]%’ OR content LIKE ‘%$word[3]%’ OR backupID LIKE ‘%$word[0]%’ OR backupID LIKE ‘%$word[1]%’ OR backupID LIKE ‘%$word[2]%’ OR backupID LIKE ‘%$word[3]%’ ORDER BY backupID DESC;
as you can see I have used explode to put each word in an array (also explode only occures when there is a space which is a problem cause comma and other things dont work) and I only check the first 4 words (cause I was pretty sure noone would go above that) but this is not the best solution, … it could possibly be the wrost!
3) Now I want to be able to use quotes in my search so for example if someone writes “big brother” it will only find matches with “big brother” and not maches with the word big alone or the word brother alone.
Thanks in advance.