简体   繁体   English

tokeninput jquery php:显示所有结果

[英]tokeninput jquery php : show all results ever

i need help on my script. 我需要有关脚本的帮助。

I create my file PHP : 我创建我的文件PHP:

# Perform the query
$query = sprintf("SELECT ID,CATEGORIA from INTUITcategoria ORDER BY CATEGORIA", mysql_real_escape_string($_GET["q"]));
$arr = array();
$rs = mysql_query($query);

# Collect the results
while($obj = mysql_fetch_object($rs)) {
    $arr[] = $obj;
}

# JSON-encode the response
$json_response = json_encode($arr);

# Return the response
echo $json_response;

and JSON result seems ok and is this : 和JSON结果似乎还可以,这是:

 {"ID":"73","CATEGORIA":"RADIOMICROFONI"}, {"ID":"68","CATEGORIA":"ACCESSORI RADIOMICROFONI"}, {"ID":"34","CATEGORIA":"ACCORDATORI "}, ............ 

Now set my html file in this way : 现在以这种方式设置我的html文件:

>     <div>
>         <input type="text" id="demo-input-facebook-theme" name="blah2" />
>         <input type="button" value="Submit" />
>         <script type="text/javascript">
>         $(document).ready(function() {
>             $("#demo-input-facebook-theme").tokenInput("../categorieautocomplete.php",
> {
>                 theme: "facebook"
>             });
>         });
>         </script>
>     </div>

But i have a problem. 但是我有一个问题。 When i digit "ACC" into input text, i receive entire list and not filter on "ACC". 当我在输入文本中输入“ ACC”时,我会收到整个列表,而不是在“ ACC”上进行过滤。

Have an ideas for solve this ? 有解决这个问题的想法吗?

Thank's in advance 提前致谢

Stefano 斯特凡诺

$("#demo-input-facebook-theme").tokenInput("../categorieautocomplete.php",

You are not passing the parameter to the script, so if it is empty then it give you all rows. 您没有将参数传递给脚本,因此,如果该参数为空,则它将为您提供所有行。 You need to pass the "q" parameter to the script. 您需要将“ q”参数传递给脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM