This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code?
Thanks
<Table cellspacing=1 cellPadding=1 align=center>
<td colspan=4>
<h2 align=center>Bomba inventory searching system</h2>
<tr>
<td>
<h4 Balai Bomba Inventory Searching System</H4>
<form name="search" method="post" action="<?=$PHP_SELF?>">
Search for:
<br><input type="text" name="search">
<br><Select NAME="field">
<Option VALUE="Operasi">Operasi</option>
<Option VALUE="Balai">Balai</option>
<Option VALUE="Komunikasi">Komunikasi</option>
</select>
<br><input type="submit"name="Submit"value="Submit"/>
</form>
<?
//required file for database connection
require("config.php");
if (isset($_POST['search'])) {
$search = mysql_real_escape_string($_POST["search"]);
$field=mysql_real_escape_string($_POST["field"]);
echo "<h2>Results</h2><p>";
//If they did not enter a search term we give them an error
if ($search== "") {
echo "<p>You forgot to enter a search term";
}
//Now we search for our search term, in the field the user specified
$data ="SELECT * FROM listofitem ";
if($field=='Operasi'){
$data .="AND listofitem.NamaPeralatan LIKE'%search%'";}
elseif($field=='Balai'){
$data .="AND listofitem.NamaPeralatan LIKE '%search%'";}
elseif($field=='Komunikasi'){
$data .="AND listofitem.NamaPeralatan LIKE'%search%'";}
$result=mysql_query($data);
//echo "<tr><td bgcolor='#CCCCFF'>ID</th><td bgcolor='#CCCCFF'>NamaPeralatan</th><td bgcolor='#CCCCFF'>Jenama</td> </tr>";
//And we display the results
if($result && (mysql_num_rows($result))>0){
while($row = mysql_fetch_assoc( $result )){
echo "<tr><td><a href='InformationPage.php?id={$row['ID']}'>{$result['ID']}</a></td>
<td><a href='InformationPage.php?id={$row['NamaPeralatan']}'>{$result['NamaPeralatan']} </td>
<td>{$row['Jenama']}</td>
</tr>";
echo" <b>Searched For:</b> " .$search;
}
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($result);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
}
//And we remind them what they searched for
?>
<a href='AddNew(operasi).php?id=Search Again'>AddNew(Operasi)</a>
<a href='AddNew(Balai).php?id=Search Again'>AddNew(Balai)</a>
<a href='AddNew(Komunikasi).php?id=Search Again'>AddNew(Komunikasi)</a>