我想自动完成并从数据库中获取数据
这是我的代码:
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
$(function() {
$( "#tags" ).autocomplete({
source: 'consultation/commande_tags.php'
});
});
</script>
<form method="post" action="#" class="formstyle1">
<input type="type" name="piece_a_commander" id="tags" placeholder="Réference " />
</form>
json页面
<?php
if($_GET["term"]){
include "includes/connexion_bdd.php";
$ref=mysql_real_escape_string($_GET["term"]);
$rq_tags="SELECT * FROM piece WHERE reference_p LIKE '%".$ref."%' ";
$ret_tags=mysql_query($rq_tags) or die (mysql_error());
$array = array();
while ($tab_tags=mysql_fetch_array($ret_tags)){
array_push($array,$tab_tags['reference_p']);
}
echo json_encode($array );
}
?>
我看不到任何建议,请帮我看看错误在哪里?