Use these to jump around or read it all…
My guess is that most of you came by this page through using the Goodies Search Engine or through the Database tutorial.
Either way (or neither way) this tutorial will finally answer one of the most asked questions in the Goodies mailbox — How do I set up a searchable database for my own Web site?
Read on…
If you haven’t yet seen my search engine work, here’s a link to it.
Give it a try and see if you like it. I do.
The searchable database was created in JavaScript and submitted to HTML Goodies by Satadip Dutta, who has given me permission to use and distribute this script. It’s a wonderful gift. If used correctly, it will allow you to set up a searchable database of your own site
for anyone with a JavaScript-enabled browser to use.
I like this one so much because it acts like the common search engine such as Yahoo or Webcrawler. Plus it accepts multiple words. Other JavaScript databases did not.
Okay, enough yackin’! (Can you “yak” in writing?) Let’s make a database.
First you need the script. I have a link to it below. But first, please understand that the author has a few requirements for you to use this script:
- Keep the copyright comments in place.
- Do not alter the script except to add your pages to search.
- If you are a non-profit site, you may use it as long as you keep the copyright comments in tact.
- If you are a for-profit site, you must first ask the author’s permission.
You’ll notice in my database version that a line was added by the author stating that I have permission to use it, as HTML Goodies is a for-profit site.
Read what’s below… please?!
I cannot stress this enough: You must get the entire script and this is a big pup. I have tested the script you get above three times. It works. If you download it and it doesn’t run, it is either your browser, the download, or the use of margins when you edited it.
Remember that JavaScript must be in the same shape when it is posted to your site as when you grabbed it. If it isn’t, then it won’t work. Always edit the scripts in an editor without margins, like NotePad or SimpleText. Just widening your margins to their widest point will not do it.
In all honesty, 99% of all troubles people have with scripts from my site are solved by losing the margins. Here’s a tip: When you get an error, go to that line (from the top of the page, not the top of the script), and see if moving the line below it up doesn’t solve the problem. Also, fix one error at a time. Do the one earliest in the script first. You see, that may be the only true error. The others may be caused by that one goof-up.
Read what’s above… please?!
Now that you have the script, you’ll need to change one thing, and begin adding your pages to the script. Let’s start with adding items to search. See these little groupings about halfway down the script?
title[#]=”yahoo search engine”
desc[#]=”the yahoo search engine”
links[#]=”http://www.yahoo.com”
matched[#]=0
You need to add and alter one of those for every page you want this thing to search. Here’s what’s happening:
- title[#]=”yahoo search engine”
The words inside the quote marks are the words the script searches. Separate the words you put in by a space. These are the items searched, so make them descriptive. There is no limit to how many you can use, but remember, the more you use, the larger the script, thus the longer it takes to load and search.
- desc[#]=”the yahoo search engine”
This is the description that appears on the results page.
- links[#]=”http://www.yahoo.com”
The is the link that is offered.
- matched[#]=0
Don’t touch this except to change the # to a number. This stays the same no matter what number of pages you enter.
- Be sure to make the number increase as you add pages.
You will use the same number for each grouping. The first grouping of four all get the number 1. The second group of four all get the number 2, and so on. If you fail to do this, you will get a lot of errors — one for every page out of order.
Just add pages until you get in all you want to be searched. Once you’re done, look for this line in the script:
Change that number 6 to whatever number of pages you have entered. My Goodies Search page has 96, I think. If you don’t change the number, only the first six will be searched.
That’s how you do it. It’s time-consuming, let me tell you, but worth it. Just remember, the more pages and code words that you use, the larger the page will be and the longer it will take to search and download.
Hopefully this will help a great deal. It will certainly lighten my e-mail.