Internal Site Search for small website

I have made a 15 page website for a client and added the customizable google search facility but he wants his own search results and not this google one.

I only have very basic knowledge of PHP and have been searching for a script for what seems like a lifetime but they are either too complex or outdated.

As the site is so small and the only search facility needs to be for the items he has for sale (just old second hand stuff, furniture etc) does anyone know of a basic, easy to use script I could use please?

Sorry I know this has probably been asked lots before but Ive looked everywhere i can and used all the search terms I can think of and am a bit stumped


Hi there,

Is your website database driven (i.e. is the searchable content stored in a database) or is it static?
Also, would your client be willing to pay for this additional functionality?

If your website is database driven, use something like this quick script I wrote to fetch the name, author, and URL link to ebooks in a virtual library:




@mysql_select_db($database) or die("Unable to select database!");

$query="SELECT * FROM books_all WHERE Title = '$title' AND Author = '$author' AND url LIKE 'h%'";




if ($num == "")

	echo "No results! <br><p></p><a href=> Go back </a>";


echo "<h3> Search Results: </h3>";


while($i < $num) {





That script is not really what the OP is looking for:

  1. Any input provided by the user should always be considered unsafe, it should be sanitized.
  2. When sending a query to MySQL, you should use prepared statements (please read up on what SQL Injection is)
  3. The mysql_* extension is out of date and is deprecated as of the current version of PHP and will likely be removed from the next version of PHP.
  4. You close the connection to the database before getting the search results which can never be accessed as there is no connection to the database over which they can be accessed.
  5. There are functions in the mysqli_* and PDO extensions which can be used to get an array containing the entire result set in one hit.
  6. You’re only fetching the results did you intend to display (echo) them?
  7. When using any SELECT query, only select the fields that you need.

I hit “post” before including the disclaimer that the above is just a concept, not something that should be copied and pasted, my apologies.

If you want to REALLY keep it simple, I use the site search from on two of my websites and it seems to work great. You can see it working here:

I do need to figure out how to get Google Analytics to record what search terms people enter in the box. So if anybody knows, please share…

Good luck!