<?php
include("../includes/connect.php");

$locality = $_POST['city'];
$affisso = str_replace("+"," ",$_POST['term']);

$strade = $connection->query("SELECT DISTINCT street FROM geopc_streets WHERE locality='$locality' AND street LIKE '%$affisso%' ORDER BY street LIMIT 0,10");

$strade = $strade->fetchAll(PDO::FETCH_COLUMN);

sort($strade);

if(count($strade) > 0)
{
	$strade = json_encode($strade);
	echo "{\"success\":true,\"streets\": $strade }";
}
else
{
	echo "{\"success\":false\" }";	
}

?>

