Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

autocomplete dynamic with data pass #108

Open
lucafrassineti opened this issue Oct 21, 2015 · 2 comments
Open

autocomplete dynamic with data pass #108

lucafrassineti opened this issue Oct 21, 2015 · 2 comments

Comments

@lucafrassineti
Copy link

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?

@dyve
Copy link
Owner

dyve commented Oct 21, 2015

Best to ask on StackOverflow, this project is abandoned.

@lucafrassineti
Copy link
Author

thanks dyve

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants