i have two input field, the first have autocomplete with cities names, I need to set the second field zone, with autocomplete filtered by selected city... i tried this but dont work...
$("#zone").focus(function(){
var c = $('#city').val();
$('#zone').autocomplete({
source: '/auto_q_int.php?city=' + c
});
});
auto_q_int.php is:
class Autocomplete
{
public $term;
public $conn;
public function __construct()
{
$this->dbConnect();
$this->term = mysql_real_escape_string($_GET['term']);
}
private function dbConnect()
{
$this->conn = mysql_connect(HOST,USER,PASSWORD) OR die("connection failed");
mysql_select_db(DB, $this->conn) OR die("no db selected");
}
public function printResult()
{
$sql = "SELECT zone
FROM zones
WHERE zone LIKE '%$this->term%' && id = '$_GET[city]'
ORDER BY zone ASC";
$res = mysql_query($sql, $this->conn);
$return = array();
$arr = array();
while($row = mysql_fetch_array($res))
{
array_push($return, $arr);
}
echo json_encode($return);
}
}
$autocomplete = new Autocomplete();
$autocomplete->printResult();
some help please?