<?php
error_reporting(0);
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
// PDO connect *********
include_once('../config/minho.php');
function connect() { 
	$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;  
    return new PDO($dsn, DB_USER, DB_PASS, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
}

$pdo = connect();
$keyword = '%'.$_POST['keyword'].'%';

$sql = "(SELECT DISTINCT(Bank) FROM buyer_cheque_monitoring WHERE Bank LIKE (:keyword)) UNION (SELECT DISTINCT(ReplaceBank) FROM buyer_cheque_monitoring WHERE ReplaceBank LIKE (:keyword)) ORDER BY Bank ASC LIMIT 0, 10";
$query = $pdo->prepare($sql);
$query->bindParam(':keyword', $keyword, PDO::PARAM_STR);
$query->execute();
$list = $query->fetchAll();
foreach ($list as $rs) {
	// put in bold the written text
	$bank_name = strtoupper(str_replace($_POST['keyword'], '<b>'.$_POST['keyword'].'</b>', $rs['Bank']));
	// add new option
    echo '<li onclick="set_item2(\''.str_replace("'", "\'", $rs['Bank']).'\')">'.$bank_name.'</li>';
}
?>