<?php



//include_once ('database_connection.php');
/*Define constant to connect to database */
DEFINE('DATABASE_USER', 'getidbiz_getidw');
DEFINE('DATABASE_PASSWORD', 'g3t!d');
DEFINE('DATABASE_HOST', 'localhost');
DEFINE('DATABASE_NAME', 'getidbiz_wines2u');



// Make the connection:
$dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD,
    DATABASE_NAME);

if (!$dbc) {
    trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}

if(isset($_GET['keyword'])){
    $keyword = 	trim($_GET['keyword']) ;
//$keyword = mysqli_real_escape_string($dbc, $keyword);


$ld=$this->session->userdata('lang_id');
$query = "SELECT * FROM products JOIN product_details ON products.id=product_details.p_id WHERE product_details.lang_id=".$ld." AND products.published='Yes' AND (product_details.name LIKE '%$term%' OR product_details.description LIKE '%$term%' OR product_details.suggestions LIKE '%".$term."%' OR product_details.characteristics LIKE '%$term%' OR product_details.vinifications LIKE '%$term%' OR product_details.microclimate LIKE '%$term%' OR product_details.other_characteristics LIKE '%$term%')";

//"select topictitle,topicdescription from topics where topictitle like '%$keyword%' or topicdescription like '%$keyword%'";

//echo $query;
$result = mysqli_query($dbc,$query);
if($result){
    if(mysqli_affected_rows($dbc)!=0){
          while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
     echo '<p> <b>'.$row['name'].'</b> '.$row['price'].'</p>'   ;
    }
    }else {
        echo 'No Results for :"'.$_GET['keyword'].'"';
    }
  
}
}else {
    echo 'Parameter Missing';
}




?>