I have a task to make a search module in which i have database users and tablename userProfile and i want to search profile when i entered text in text box for ex. if i entered "I am looking for MBA in delhi" or 'mba information in delhi' it will displayed all user registered expertise as mba and city in delhi . this will be like job portal or any social networking portal
my database is
-- phpMyAdmin SQL Dump
-- version 2.8.1
-- http://www.phpmyadmin.net
-- Host: localhost
-- Generation Time: May 01, 2010 at 10:58 AM
-- Server version: 5.0.21
-- PHP Version: 5.1.4
-- Database: users
--
-- Table structure for table userProfile
CREATE TABLE userprofile (
id int(11) NOT NULL auto_increment,
name varchar(50) collate latin1_general_ci NOT NULL,
expertise varchar(50) collate latin1_general_ci NOT NULL,
city varchar(50) collate latin1_general_ci NOT NULL,
state varchar(50) collate latin1_general_ci NOT NULL,
discription varchar(500) collate latin1_general_ci NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;
--
-- Dumping data for table userProfile
INSERT INTO userProfile VALUES (1, 'a', 'MBA HR', 'Delhi', 'Delhi', 'Fortune is top management college in Delhi, Best B-schools in India providing business studies and management training. FIIB is Delhi based most ranked ...');
INSERT INTO userProfile VALUES (2, 'b', 'MBA marketing', 'Delhi', 'Delhi', 'Fortune is top management college in Delhi, Best B-schools in India providing business studies and management training. FIIB is Delhi based most ranked ...');
and search.php page
<?php
include("config.php");
include("class.search.php");
$br=new search();
if($_POST['searchbutton'])
{
$str=$_POST['textfield'];
$brstr=$br->breakkey($str);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<body>
<table width="100%" border="0">
<form name="frmsearch" method="post">
<tr>
<td width="367"> </td>
<td width="300"><label>
<input name="textfield" type="text" id="textfield" size="50" />
</label></td>
<td width="294"><label>
<input type="submit" name="searchbutton" id="button" value="Search" />
</label></td> </tr></form> <tr>
<td> </td>
<td> </td>
<td> </td> </tr> <tr>
<td> </td>
<td> </td>
<td> </td> </tr> </table> </body> </html>
and config.php is
<?php
error_reporting(E_ALL);
$host="localhost";
$username="root";
$password="";
$dbname="users";
$con=mysql_connect($host,$username,$password) or die("could not connect database");
$db=mysql_select_db($dbname,$con) or die("could not select database");
?>
and class.search.php is
<?php
class search
{
function breakkey($key)
{
global $db;
$words=explode(' ',$key);
return $words;
}
function searchitem($perm)
{
global $db;
foreach($perm as $k=>$v)
{
$sql="select * from users"
}
}
}
?>