Site Search Script

My Javascript Site Search Script relies on your manually updating the script source every time you want to add a page. It also relies on your visitors having Javascript enabled in order for the search to work. A better solution is to use server side processing to provide the site search functionality.

This site now uses a PHP site search script.

When I first switched to server side processing I used a plain text file to contain the information to be searched (searching the pages themselves is way too slow). Because that version of the search function uses a plain text file it can be used on sites that do not have access to a database. While administrator options are also provided to allow search criteria to be extracted directly from pages or manually entered having the data in a flat file also allows the data to be manually edited when this is the easier option.

I have recently switched to using a MYSQL database to hold the data to be searched and improved the edit functionality on the admin page to allow partial lists of the search entries to be displayed.

I am now offering not one but both of these PHP versions of my search script for you to purchase to use on your own site. These search scripts offer the following functionality:

  1. A search function that searches a flat file or database for occurrences of the entered search term, a much faster option than searching the page source themselves.
  2. Ability to "spider" a folder and add all of the web pages to your search. The h1 (or where there is no h1, the title), meta description, and meta keywords are extracted from each page and stored in the file or database. Any meta robots entry that specifies "index,follow", "index,nofollow", "noindex,follow", or "noindex,nofollow" is obeyed in determining which pages in the folder to include. As only the specified folder is affected the spider can be run separately for each folder containing web pages on a multi-folder site. If the PHP setup on your server has the allow_url_fopen option set on then you can even spider other web sites to include in your search.
  3. Option to either just display the results of spidering a folder or actually update the database or file. With the file version you can either create a temporary file to cut and paste entries across into the main file or alternatively add all of the entries directly into the main table overwriting any entries already there for the same page. With the database version any entries for the folder that you have not edited will be deleted from the database and replaced with the current results. Results for pages that you have manually edited will not be overwritten.
  4. The database version also offers a single page option to add or overwrite the entry for a specified page. This allows you to quickly add new pages to your search without having to re-spider the entire folder.
  5. Both versions also have a manual edit option allowing you to update or add entries to the file or database manually. This option is useful for adding entries for link points within pages to the database or file.
    The database version allows you to specify part of the URL of the entries that you wish to look at (eg. entering 'b' will display only those entries where the URL starts with 'b', entering '%job' will display all of those entries where the URL contains 'job' anywhere in the URL, '%' will give a complete list). If no value is entered to restrict the list of entries then all of those entries previously edited will be listed. This allows you to limit the number of entries being listed which speeds the processing when you have a large number of entries.
  6. For those pages being searched that are in the base directory of the search you can define an associated image to be displayed on the search results page alongside that page reference. To display an image next to an entry in the results you must have a gif, jpg, or jpeg image in the subdirectory defined by the $imgdir parameter that has the same filename as the page to be listed (disregarding the page extension). For example if you set $imgdir to 'image/' and you have a page called mypage.htm that is to be listed in the search results and 'image/mypage.gif' exists then that image will be displayed alongside the entry in the results page.
  7. Fully customisable results page. You simply define how you want your results page to look using a template file and special markers that indicate where in the page that the particular result fields are to be put.

The following information will assist you in determining if my search facility will work on your site. Once you have decided then the "buy now" link at the bottom of the page can be used to purchase the script. Further information on how to configure and install the script can be found in the readme.txt file supplied with the script.

Will it run on my server?

To be able to use this script you should first Check the Server to ensure that your host supports PHP.

In order to be able to use the online admin functions to update the search table with the flat file version you must have the find.tbl and findtmp.tbl files configured so as to be updateable. If your server does not allow these files to be updated online then you will be unable to use the admin page to update your search table. In this instance you can still use the flat file version of the search script but you will have to manually edit find.tbl on your computer and then ftp it to the site whenever you want to make changes.

How it Works

The site search script basically provides you with three web pages to add to your site. The first (search.htm) provides the input form where your visitors specify what they want to search for. The second (result.php) loads your template with a list of all of the pages that satisfied the search criteria sorted so that the best matches are at the top. The third page (admin.php) provides you with the functions that you need to update the search table when you add or alter the pages on your site. This third page contains built in password protection to stop your visitors updating the table.

The flat file version of the search table contains six entries for each page that you want listed (separated by tildes '~'). These are:

The database version has the same six fields plus an additional one to keep track of which entries have been manually edited so as to stop them being overwritten by subsequent folder spidering. I have a demo of how the build function extracts data to build the search table on my site search admin page, just log on as "guest". I don't have a demo of the edit function but the following shows what the edit screen looks like (reduced to about 75% of actual size):

Search Table Editor

The edit function looks the same with both versions. The difference is that the flat file version always lists all entries while the database version only lists the subset of entries that matches the partial URL you entered. The database version also has an option at the bottom of the list to change the subset that you are listing.

When your visitor searches for a given search string then the string will be compared with each of the keywords in each entry in the table and also each word entered will be separately compared to the description. Any that match will be provided in the results to be displayed with those that achieved multiple matches appearing first. If you allow your visitors to specify a cetegory and/or subject then the results will be further limited to entries that match on those fields as well. The results list shows the results in order of relevance in whatever format your template defines. For a demo of how this works just search my site using the search field at the top of this page.

Script Components

There are a number of files that contribute to the search function. The following is a list of the included files so that you know what you are getting :

A description of what each of these files is for in the readme.txt file that is supplied with the script.


First decide whether you are going to use the flat file or database version. For the flat file version you can discard the content of the db folder and move everything from the flat folder into the main folder. For the database version discard the flat folder and move everything in the db folder to the main folder.

Before you upload the site search function to your site you first need to configure it for your site. The first step is to update admin.php, search.htm, and result.tpl to give those three pages a similar apprearance to the other pages on your site so that the site search looks like it belongs to your site.

The next step is to update config.php with the parameters that you require for your site. A description of what each parameter is for can be found in the readme.txt supplied with the script.

If you are going to use the database version then you need to upload the config.php, db.php, and rwl.php files next and create the database. You do this by running: (substitute your userid and password as defined in the config.php file)


You can now upload the rest of the files to your site and test them to make sure that they look and function as you expect.

You will now want to use the admin page to build/edit your search results table so that it contains entries for all of the pages on your site that you want your visitors to be able to search.

The final step to implement the search script on your site is to provide links to search.htm from the other pages of your site.

You can also convert from one version of the script to the other at any time. Instructions on how to do this are in the readme.txt.

How to obtain the script

Unfortunately, I have to try to fund the running of this web site somehow and so I have decided to charge a nominal amount for server side scripts such as this one. Use the following form to purchase both versions of the Felgall Site Search script together for just $29.00 USD (Australian residents price is $29.00 AUD including GST). All purchases include 12 months free support including all updates to the script released during that time. If you have a valid discount code then enter it to purchase this script at an even lower price otherwise just leave the discount field blank, select the currency to make your payment and then press the buy now button. The script will be automatically emailed to you as soon as Paypal verifies your payment

Before you purchase this script you should reread the above information to ensure that the script will work on your server. If you cancel at any point during the payment process, you will be returned to this page.

Software Licence

Please make sure that the email account that you supply to Paypal will accept emails with attached zip files from addresses at as otherwise your spam filtering may delete your purchase.

Discount code:
Credit Cards Accepted


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow