PHP and MySQL Search Engine - Make a search engine in PHP that searches MySQL
In this tutorial I will show you how to make a fully function search for your database. This tutorial uses "LIKE $search" but you will also learn a method I developed for my site's search. Why? Because some people will search with more than one word and if they search for say three words then it will search the database for those three words in exact order just how they searched it, which is no good if they searched keywords like "php database mysql" which would never be a sentence that you would find.
1. First we should create a table (to use as an example) for holding people's names and a little about them.
// set your infomation.
$dbhost='localhost';
$dbusername='username';
$dbuserpass='password';
$dbname = 'database';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db($dbname) or die('Cannot select database');
//create the table, customize it if you want
$query = 'CREATE TABLE people(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(30) NOT NULL,
about TEXT NOT NULL)';
$result = mysql_query($query);
echo "Table Created!";
?>

| Hits: | 176 | Last Updated: | 2006-07-18 |
VIEW ALL
PHP Tutorials