Below is my idex code about search engine. The all function was no problem but it still run to one error like this:
Notice: Undefined variable: searching in C:\server\Apache2\htdocs\MySearchEngine\index.php
Can somebody help me to check it out?
<?
<form name="search" method="post" action="<?=$PHP_SELF?>">
Search for:
<br><input type="text" name="find" />
<br>
<Select NAME="field">
<Option VALUE="Operasi">Alat Operasi</option>
<Option VALUE="Balai">Alat Balai</option>
<Option VALUE="Komunikasi">Alat Komunikasi</option>
</Select>
<Select NAME="field2">
<Option VALUE="Bermotor">Alat Bermotor</Option>
<Option VALUE="Tidak Bermotor">Alat Tidak Bermotor</Option>
</Select>
<input type="submit"name="searching"value="Search"/>
<input type="hidden" name="searching" value="yes" />
</form>
<?
//required file for database connection
require("config.php");
/ Get timestamp before executing the query: /
$start_time = getmicrotime();
//This is only displayed if they have submitted the form
if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM listofitem WHERE upper(($field)LIKE '%$find%' OR NamaPeralatan LIKE'%$find%')AND Motor='$field2'" );
echo "<tr><td bgcolor='#CCCCFF'>ID</th><td bgcolor='#CCCCFF'>NamaPeralatan</th><td bgcolor='#CCCCFF'>Jenama</td> </tr>";
//And we display the results
while($result = mysql_fetch_array( $data ))
{
echo "<tr><td><a href='InformationPage.php?id={$result['ID']}'>{$result['ID']}</a></td>
<td>{$result['NamaPeralatan']}</td>
<td>{$result['Jenama']}</td>
</tr>";
}
//close out your table
echo "</table>";
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query";
}
//And we remind them what they searched for
echo "<br><b>Searched For:</b> ".$field2 ;
echo "<b> >> </b> ".$field ;
echo "<b> >> </b> ".$find ;
echo"<br>";
}
?>