<?php require_once('../db.php'); ?>
<?php
	if (isset($_GET["sq"]) && $_GET["sq"] != "") {
		try {
			$core = Core::getInstance();
			$stmt = $core->dbh->prepare("SELECT * FROM prices WHERE country like :entercountry or country = :country");
			$stmt -> bindValue("entercountry", $_GET["sq"].'%');
			$stmt -> bindParam("country", $_GET["sq"], PDO::PARAM_STR);
			$stmt -> execute();
			$results = $stmt -> fetchAll(PDO::FETCH_ASSOC);
			echo json_encode($results);	
		} catch(PDOException $pe) {
			trigger_error('Could not connect to MySQL database. ' . $pe->getMessage() , E_USER_ERROR);
		}
	}
?>