jqgrid autocomplete & PHP
JS:
{name:'client', index:'client', width:40, editable:true, editoptions:{ dataInit : function (elem) {$(elem).autocomplete({source:
function(request, response){
$.getJSON('query_task_setting.php',{'type':'client','name':request.term},function(data){//request.term 為目前keyin 的字串
var arr=[];
$(data).each(function(index){
arr.push(data[index].client);
})
response(// return 搜尋到的字串
arr )
})
}
})}}}
PHP:
include("class/mysql_to_json.class.php");
$colname_Recordset1 = "-1";
if (isset($_GET['type'])) {
$type = $_GET['type'];
}
if(isset($_GET['name'])){
$name= $_GET['name'];
}
mysql_select_db($database_loading_sys_conn, $loading_sys_conn);
$query_Recordset1 = "SELECT $type FROM task_settings group by $type having $type like '%$name%'";
$mtj = new mysql_to_json($query_Recordset1);
echo $mtj->get_json();
沒有留言:
張貼留言