Page 1 of 1

Script for adding search facility in a site

Posted: Thu Feb 05, 2004 10:36 am
by vivekjain
Hi,
I would like to know how to add a search facility in a website using PHP. If you know of any resources kindly let me know. Thanks

Posted: Thu Feb 05, 2004 11:18 am
by kettle_drum
You would usually have most of the data on the site - i.e. forum posts, news items, articals, tutorials etc - stored in a database and then you simply search it for the keyword the user entered:

SELECT * FROM table WHERE data_text LIKE '%$search_phrase%';

If you dont store the site data in a database then things are a bit more complicated, but work on the same process - you just have to search the individual pages on your site.

To speed things up you could put keywords for each page of your site into a search file, then php can search this file to get quick results.