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
Script for adding search facility in a site
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
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.
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.