what i want to do is allow users of my site it search my database, using keyword(s) or phrases?
for example, if they type 'planets', then it will list any news/articles with the word 'planets' in it. and if they enter '"jupiters moons"' (with the "") it will find only the records with "jupiters moons" some where in it.
im not sure how to do this, so any help would be great
cheers
Andrew
search?
Moderator: General Moderators
- AndrewBacca
- Forum Commoner
- Posts: 62
- Joined: Thu Jan 30, 2003 10:03 am
- Location: Isle of Wight, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you are using MySQL you can use the LIKE keyword:
http://www.mysql.com/doc/en/String_comp ... ml#IDX1216
Mac
Code: Select all
SELECT field1, field2, field3 FROM table WHERE field1 LIKE '% keyword %'Mac
- AndrewBacca
- Forum Commoner
- Posts: 62
- Joined: Thu Jan 30, 2003 10:03 am
- Location: Isle of Wight, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Would that find planet in:twigletmac wrote:You can still use LIKE for that, as in the example I gave, just put spaces between the keyword and the wildcards (%).McGruff wrote:And to get "planet" but not "planetary"
RLIKE '[[:<:]]" . $value . "[[:>:]]'
Mac
"... the red planet. New sentence ..etc.."
or
".. planet-forming .."
ie are non-alphabetic chars like punctuation or dashes treated as spaces?
Not trying to be a smartass - that's why I use RLIKE but maybe I don't need to.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK