Well I'm back again with another idea, try using this script:
<?php
require_once('inc/global.inc.php');
# search.inc.php
/*
* This is the search content module.
* This page is included by index.php.
* This page expects to receive $_GET['terms'].
*/
// Redirect if this page was accessed directly:
if (!defined('BASE_URL')) {
// Need the BASE_URL, defined in the config file:
require_once ('../includes/config.inc.php');
// Redirect to the index page:
$url = BASE_URL . 'index.php?p=search';
// Pass along search terms?
if (isset($_GET['terms'])) {
$url .= '&terms=' . urlencode($_GET['terms']);
}
header ("Location: $url");
exit;
} // End of defined() IF.
// Print a caption:
echo '<h2>Search Results</h2>';
// Display the search results if the form
// has been submitted.
if (isset($_GET['terms']) && ($_GET['terms'] != 'Search...') ) {
$terms = $_GET['terms'];
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die *('Error connecting to MySQL server');
// Query the database.
$query = "SELECT * FROM product WHERE title LIKE '%$terms%'";
// Fetch the results.
//$row = mysqli_fetch_array($result);
// Print the results:
$result=mysqli_query($dbc,$query);
if (!$result){
echo "<h3>Sorry,</h3>";
echo "<p>your search: "" .$terms. "" returned zero results</p>";
} else {
$output = Array();
while($row=mysqli_fetch_assoc($result)) {
$output[] = '<ul>';
$output[] = '<li>'.$row['title'] .': £'.$row['price'].'<br /><img src="'.$row['img'].'" alt="'.$row['title'].'" /></li>';
$output[] = '</ul>';
}
echo join('',$output);
}
} else { // Tell them to use the search form.
echo '<p class="error">Please use the search form at the top of the window to search this site.</p>';
}
?>