Tuesday, 4 June 2013

Advance Search Engine Using PHP

Search is used in many websites.bigneers that enter in web development are facing  a problem that how to make a search engine using i try to solve this problem in simple way.(search in php,search suggestion in php,search engine in php)

Step 1: Cteate a html search box with submit button (index.php)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search Using PHP</title>

<form action="search.php" method="post" >
<input type="text" name="search_box" />
<input type="submit" />

Step 2: Create  search.php page

            $keyword = explode(" ", $_POST["search_box"]);
            $rs="select * from table_name where name LIKE '%".$keyword['0']."%' ";
                for ($i=1; $i<count($keyword); $i++) {
                $rs = $rs."AND name LIKE '%".$keyword[$i]."%' and name LIKE '%".$keyword[$i]."%'    and name LIKE '%".$keyword[$i]."%' and product_name LIKE '%".$keyword[$i]."%'";

                     echo $row["name"];

No comments: