<?php
$dbuser 
"db_username"// REPLACE db_user with the username used to connect to your database
$dbpass "db_password"// REPLACE db_pass with the password used to connect to your database
$database "database"// REPLACE database with the name of your database
mysql_pconnect("localhost",$dbuser,$dbpass);
mysql_select_db($database);
$keywords strip_tags(trim($_GET['q']));
$keywords preg_replace("/\-/"" "$keywords);
$table "visitors";
$db_visitor_date time();
$db_ip "'".$_SERVER['REMOTE_ADDR']."'";
$db_keyword "'".$keywords."'";
$sql "INSERT INTO $table SET visitor_date = $db_visitor_date, ip = $db_ip, keyword = $db_keyword";
$query mysql_query($sql);
$keyword_array explode(" "$keywords);
foreach (
$keyword_array as $keyword) {
    if (!empty(
$keyword)) {
        
$extra .= "Name LIKE '%".$keyword."%' || ";
    }
}
$extra trim($extra"|| ");
$table "naturehills";
$sql "SELECT * FROM $table WHERE $extra ORDER BY ABS(Price) DESC";
$query mysql_query($sql);
while (
$row mysql_fetch_array($query)) {
    
$product_id $row['ProductID'];
    
$name $row['Name'];
    
$bigimage $row['BigImage'];
    
$price $row['Price'];
    
$description $row['Description'];
    
$results .= "<tr>\n<td valign=\"top\"><a href=\"go.php?n=".$product_id."&k=".urlencode($keywords)."\"><img src =\"".$bigimage."\" title=\"".$name."\" / border=\"0\"></a></td>\n<td valign=\"top\"><strong>".$name."</strong><br />".$description."<br />".$price."</td>\n</tr>\n";
    
$count++; 
    if (
$count 30) break;
}
if (
$count 1) {
    
$extra preg_replace("/Name/""Description"$extra);
    
$sql "SELECT * FROM $table WHERE $extra";
    
$query mysql_query($sql);
    while (
$row mysql_fetch_array($query)) {
        
$product_id $row['ProductID'];
        
$name $row['Name'];
        
$bigimage $row['BigImage'];
        
$price $row['Price'];
        
$description $row['Description'];
        
$results .= "<tr>\n<td valign=\"top\"><a href=\"go.php?n=".$product_id."&k=".urlencode($keywords)."\"><img src =\"".$bigimage."\" title=\"".$name."\" / border=\"0\"></a></td>\n<td valign=\"top\"><strong>".$name."</strong><br />".$description."<br />".$price."</td>\n</tr>\n";
        
$count++; 
        if (
$count 30) break;
    }
}
$results "<table>\n".$results."</table>\n";
echo 
$results;
?>