if(!empty($_GET['keyword']))
{
$key = $_GET['keyword'];
$sql = "select ITEMID,ITEMNAME,ITEMGROUPID from INVENTTABLE where ITEMID like '%$key%' or ITEMNAME like '%$key%' or ITEMGROUPID like '%$key%' order by ITEMID";
echo $sql;
}
if(!empty($_GET['keyword']))
{
$rs_4_json=array();
$key = $_GET['keyword'];
$sql = "select ITEMID,ITEMNAME,ITEMGROUPID from INVENTTABLE where ITEMID like '%$key%' or ITEMNAME like '%$key%' or ITEMGROUPID like '%$key%' order by ITEMID";
//echo $sql;
$qrit=mssql.........;
while($item = mssql_fetch_assoc($qrit))
{
$item['ITEMNAME']=iconv('TIS-620','UTF-8',$item['ITEMNAME']);
$rs_4_json[]=$item;
}
echo json_encode($rs_4_json);
}
Code (JavaScript)
success: function(result)
{
var rs=$.parseJSON(result);
$('#ddlLeft').empty();
$(rs).each(function(idx, obj){
var opt = '<option value="'+obj.ITEMID+'" >'+obj,ITEMNAME+'</option>';
$('#ddlLeft').append(opt);
});
}