I am now trying to do a dynamic autocomplete search from db.
What I want is when I insert 'P1', my autocomplete will display 'P1623AD' & 'P123AD'
or when I insert 'hard' then autocomplete show 'hardware'.
Current I can only search by 1 column.
My query:
$ItemDetail = array();
$getItemSQL = base_executeSQL("SELECT eitem_item_code,eitem_item_name FROM eitem_item");
while($Item_row = base_fetch_array($getItemSQL)){
$ItemDetail[]=$Item_row;
}
echo json_encode($ItemDetail);
My Jquery:
$('input#item_search').autocomplete({
source:function (request,response){
$.ajax({
type:"GET",
data:{term:request.term},
dataType:'json',
url:'search_item.php',
success:function(data){
response($.map(data, function (item)
{
// return
//alert(data[0]);
return{item.eitem_item_code,item.eitem_item_name
};
}));
}
});
},
minLength:1
});
Thanks
I know it's late reply, But it's worth of knowing it. Your query should have LIKE
condition with multiple fields I mean what are the fields you want to search with.
$getItemSQL = base_executeSQL("SELECT eitem_item_code,eitem_item_name FROM eitem_item WHERE eitem_item_code LIKE '{$_GET['term']}' OR ANOTHER_FIELD_FROM_TABLE LIKE '{$_GET['term']}'");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.