1. Computing

Simple Site Search

By , About.com Guide

1 of 5

Creating the Database
Having a search feature on your site is very handy for helping users find exactly what they are looking for. Search engines can range from something very simple like we have here, to something as huge and complicated as Google.

Our search engine tutorial assumes that all the data you want to be searchable is stored in your MySQL database. It will not have any fancy algorithms - just a simple LIKE query, but it will work for basic searching and give you a jumping off point to make a more complex searching system.

Before we can begin we need a database. The code below will create a testing database to use as you work through the tutorial.

 CREATE TABLE users (fname VARCHAR(30), lname VARCHAR(30), info BLOB); 

 INSERT INTO users VALUES ( "Jim", "Jones", "In his spare time Jim enjoys biking, eating pizza, and classical music" ), ( "Peggy", "Smith", "Peggy is a water sports enthusiast who also enjoys making soap and selling cheese" ),( "Maggie", "Martin", "Maggie loves to cook itallian food including spagetti and pizza" ),( "Tex", "Moncom", "Tex is the owner and operator of The Pizza Palace, a local hang out joint" ) 
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. PHP with MySQL
  5. php search script - php search engine - php mysql site search

©2013 About.com. All rights reserved.