consulta($sql); while($row=$db->fetch_array($result)) { $nombre.="'".$row["telefono"]."',"; $id.="'".$row["clienteid"]."',"; } substr($nombre,0,-1); substr($id,0,-1); $sg.="suggestions:[".$nombre."],"; $sg.="data:[".$id."]"; $sg.="}"; echo $sg; } if($buscar=='identificacion_cliente') { $sg= "{ query:'".$query."',"; $sql="SELECT clienteid, identificacion FROM cliente where identificacion LIKE CONVERT(_utf8 '%".$query."%' USING latin1) ORDER BY identificacion LIMIT 5"; $result= $db->consulta($sql); while($row=$db->fetch_array($result)) { $nombre.="'".$row["identificacion"]."',"; $id.="'".$row["clienteid"]."',"; } substr($nombre,0,-1); substr($id,0,-1); $sg.="suggestions:[".$nombre."],"; $sg.="data:[".$id."]"; $sg.="}"; echo $sg; } if($buscar=='identificacion_proveedor') { $sg= "{ query:'".$query."',"; $sql="SELECT proveedorid, identificacion FROM proveedor where identificacion LIKE CONVERT(_utf8 '%".$query."%' USING latin1) ORDER BY identificacion LIMIT 5"; $result= $db->consulta($sql); while($row=$db->fetch_array($result)) { $nombre.="'".$row["identificacion"]."',"; $id.="'".$row["proveedorid"]."',"; } substr($nombre,0,-1); substr($id,0,-1); $sg.="suggestions:[".$nombre."],"; $sg.="data:[".$id."]"; $sg.="}"; echo $sg; } if($buscar=='nombre_proveedor') { $sg= "{ query:'".$query."',"; $sql="SELECT proveedorid, nombre FROM proveedor where nombre LIKE CONVERT(_utf8 '%".$query."%' USING latin1) ORDER BY nombre LIMIT 5"; $result= $db->consulta($sql); while($row=$db->fetch_array($result)) { $nombre.="'".$row["nombre"]."',"; $id.="'".$row["proveedorid"]."',"; } substr($nombre,0,-1); substr($id,0,-1); $sg.="suggestions:[".$nombre."],"; $sg.="data:[".$id."]"; $sg.="}"; echo $sg; } if($buscar=='producto') { $sg= "{ query:'".$query."',"; $sql="SELECT productoid,codigo, producto FROM productos where producto LIKE CONVERT(_utf8 '%".$query."%' USING latin1) or codigo LIKE CONVERT(_utf8 '%".$query."%' USING latin1) ORDER BY codigo,producto LIMIT 5"; $result= $db->consulta($sql); while($row=$db->fetch_array($result)) { $nombre.="'".$row["codigo"]." - ".$row["producto"]."',"; $id.="'".$row["productoid"]."',"; } substr($nombre,0,-1); substr($id,0,-1); $sg.="suggestions:[".utf8_encode($nombre)."],"; $sg.="data:[".$id."]"; $sg.="}"; echo $sg; }