autocomplete source

autocomplete source

pearly_030pearly_030 Posts: 42Questions: 0Answers: 0
edited October 2011 in General
Hello,

When I code "source : ["bus", "voiture", "moto", "velo"]", the aucompletion is OK
[code]
$("#exemple").autocomplete({
source : ["bus", "voiture", "moto", "velo"]
});
[/code]

But when I code " source: 'liste_sites.php' " , the result is KO, All entries are always displayed
while the response in debug mode is ["bus", "voiture", "moto", "velo"]

[code]
$("#exemple").autocomplete({
source: 'liste_sites.php'
});
[/code]

liste_sites.php:
[code]
$query = "SELECT libelle FROM sites";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
$sites['$x'] = $row['libelle'];

if ($x == 0) {$liste_sites = $liste_sites.$sites['$x'];}
if ($x <> 0) {$liste_sites = $liste_sites.'", "'.$sites['$x'];}
$x = $x + 1;
}
$liste_sites = $liste_sites.'"]';
echo $liste_sites;
[/code]

Can you help me ?
Thanks
This discussion has been closed.