我的代码工作正常,唯一的问题是我的用户只能在数据库中搜索11个单词,如果他们退格删除一定的话。看看我的SELECT IN语句,我只输入11个数组,因为我只允许用户输入11个关键字,这是有意义的。但是,我允许用户退格删除。所以,如果用户退格删除三,系统仍然会计算那些删除字。当用户输入第8个字时,系统统计三个删除字和输入字,系统将不会在第8个字后搜索该字。我提出了一个想法,我手动输入$ term_0到$ term_100。但我不知道这是否会降低速度。我也考虑jquery.length,但它不能与php select语句结合使用。你有更好的方法来实现我想要的吗?升值。
$( "#tag" ).on( "keydown", function( event ) {//search keyword
$.ajax({
url:'member_search.php',
type:'POST',
cache: false,
data:{
search_text: $(".result_tag").text()
},
success: function(data){
$("#find_user").val(data);
}
});
});
//delete keyword
$(document).on("click", "img", function() {
$.post("delete.inc.php", {
tag : $(this).closest("span").text(),
users_id : $("#users_id").val()
},
if ($(this).parent().remove()){ //remove the tag
}
});

<?php
$stm =$db->prepare("SELECT s.id, s.term, s.counter, os.user_id FROM sign s, object_sign os WHERE s.id = os.sign_id AND s.term IN (:term_0,:term_1,:term_2,:term_3,:term_4,:term_5,:term_6,:term_7,:term_8,:term_9,:term_10) GROUP BY os.user_id order by COUNT(os.user_id) DESC ");
$term_0="$term[0]";
$term_1="$term[1]";
$term_2="$term[2]";
$term_3="$term[3]";
$term_4="$term[4]";
$term_5="$term[5]";
$term_6="$term[6]";
$term_7="$term[7]";
$term_8="$term[8]";
$term_9="$term[9]";
$term_10="$term[10]";
$stm->bindParam(":term_0", $term_0);
$stm->bindParam(":term_1", $term_1);
$stm->bindParam(":term_2", $term_2);
$stm->bindParam(":term_3", $term_3);
$stm->bindParam(":term_4", $term_4);
$stm->bindParam(":term_5", $term_5);
$stm->bindParam(":term_6", $term_6);
$stm->bindParam(":term_7", $term_7);
$stm->bindParam(":term_8", $term_8);
$stm->bindParam(":term_9", $term_9);
$stm->bindParam(":term_10", $term_10);
$stm->execute();
?>
&#13;