Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Jquery UI自动完成有问题_Php_Jquery_Mysql_Jquery Ui_Mysqli - Fatal编程技术网

Php Jquery UI自动完成有问题

Php Jquery UI自动完成有问题,php,jquery,mysql,jquery-ui,mysqli,Php,Jquery,Mysql,Jquery Ui,Mysqli,我的php代码是这样的 if (isset($_REQUEST['term'])) { $term = trim(strip_tags($_REQUEST['term']));//retrieve the search term that autocomplete sends $result = $db->query("SELECT company as value,id FROM main WHERE company LIKE '$term'") or die(mysq

我的php代码是这样的

if (isset($_REQUEST['term']))
{
    $term = trim(strip_tags($_REQUEST['term']));//retrieve the search term that autocomplete sends

    $result = $db->query("SELECT company as value,id FROM main WHERE company LIKE '$term'") or die(mysqli_error());;
    $results = array();
    while ($row = $result->fetch_row()) $results[] = array( 'id' => $row[0] , 'label' => $row[1], 'value' => $row[1] );
    echo json_encode($results);
}
下面是Js代码

$("#auto").autocomplete({
    source: "index.php",
    minLength: 2,//search after two characters
    select: function(event,ui){
    }
});
和HTML标记

<input id="auto" name="company"/>


代码怎么了?它不会生成自动完成选项。。php日志文件中没有错误。如何解决这个问题?

假设json正常,那么您就不会对返回的数据进行任何处理

select: function(event,ui){
// do something with the data you get back
//you would usually have a function here to do something with data
// but this sample should be enough for you 
var id = ui.id;  // id you got back assign to var
var label = ui.label; // label you got back assign to var
$('#gothisback').val(ui.id); //push it to a div
    }

哪个部门?我想把它作为自动完成菜单拿回来