Php jQuery自动完成输出所有结果,而不是匹配字符串

Php jQuery自动完成输出所有结果,而不是匹配字符串,php,json,jquery,jquery-autocomplete,Php,Json,Jquery,Jquery Autocomplete,我对JSON和jQuery比较新。我需要进行jQuery自动完成,为此我提出: <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jqu

我对JSON和jQuery比较新。我需要进行jQuery自动完成,为此我提出:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>


<script>
jQuery(document).ready(function($){
    $('#executives').autocomplete({source:'search_executives.php', minLength:2});
});
</script>
现在我的问题是-

  • 它输出所有结果,它不依赖于我输入的搜索字符串
  • 它以HTML格式打印文本字段中的
    (例如3)。我需要打印高管的姓名,并将其
    员工id
    作为其值

  • 注:第一部分已解决。我忘了在
    SQL
    中添加
    LIKE
    条件

    您正在使用一个输入文本框。


    文本框的值属性显示在前端文本框中,您无法更改它。(即)您案例中的员工id。

    您正在使用一个输入文本框。


    文本框的值属性显示在前端文本框中,您无法更改它。(即)您的员工id。

    您必须将输入值设置为
    标签,然后在选择项目时,使用另一个字段存储
    员工id

    select: function(e, ui) {
      e.preventDefault();
      this.value = ui.item.label;
      $('#other_field').val(ui.item.value);
    }
    

    您必须将输入值设置为
    标签
    ,然后在选择项目时,使用另一个字段存储
    员工id

    select: function(e, ui) {
      e.preventDefault();
      this.value = ui.item.label;
      $('#other_field').val(ui.item.value);
    }
    

    如果我希望
    标签
    php
    中的
    属性作为其值显示在文本框中,我需要做什么?如果我希望
    标签
    php
    中的
    属性作为其值显示在文本框中,我需要做什么?
    select: function(e, ui) {
      e.preventDefault();
      this.value = ui.item.label;
      $('#other_field').val(ui.item.value);
    }