我有这个功能,它以一种形式显示自动建议:
function searchbyId($params) {
$input = strtolower($params['input']);
$len = strlen($input);
$limit = isset($params['limit']) ? (int) $params['limit']:25;
$items=array();
$sql='SELECT DISTINCT nIdentidad, CONCAT(primerNombre, ' ', segundoNombre, ' ', primerApellido, ' ', segundoApellido) AS nombre FROM tarjeta_indent WHERE nIdentidad LIKE \''.$input.'%\' ORDER BY nIdentidad LIMIT '.$limit;
$resp=db_query($sql);
if($resp && db_num_rows($resp)){
while(list($nIdentidad)=db_fetch_row($resp)) {
//$name=(strpos($name,'@')===false)?$name:'';
$items[] ='{"id": "'.$nIdentidad.'", "value": "'.$nIdentidad.'"}';
}
}
$result= '{"results": ['.implode(", ", $items).']}';
return $result;
}
但仅当我将查询更改为此时才有效:
$sql='SELECT DISTINCT nIdentidad FROM tarjeta_indent WHERE nIdentidad LIKE \''.$input.'%\' ORDER BY nIdentidad LIMIT '.$limit;
我该如何做连接部分?
谢谢。