Hallo,
I am trying to make this search box works. This is my code:
navigation.php
<?
//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;
}
// Otherwise we connect to our Database
include('con_database.php');
// 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 static_content WHERE upper($field) LIKE'%$find%'");
$data = mysql_query("SELECT * FROM static_content WHERE upper(image) LIKE '%$find%' or upper(title) LIKE'%$find%' or upper(content) LIKE'%$find%'");
//And we display the results
while($result = mysql_fetch_array($data))
{
echo '<img src="images/events/thumb/' . $result['images'] . '">';
echo " ";
echo $result['title'];
echo "<br>";
echo $result['content'];
echo "<br>";
echo "<br>";
}
//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<br><br>";
}
//And we remind them what they searched for
echo "<b>Searched For:</b> " .$find;
}
?>
<div id="search">
<form name="contact" action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">
<input type="text" name="find" placeholder="search.." value="" width="80"></div>
<input type="hidden" name="searching" value="yes" />
<div id="sbutton">
<input src="images/search button.jpg" name="submit" value="Search" type="image" width="30"></div>
</form>
</div>
My mysql:
table
static_content
column
content
image
title
I wonder after I input search text in the search box and press enter, the search result does not appears in the website.