function fetchSuggested($string) { $sql = SQLstartWith($string); $result["result"] = array(); while ($array = $sql->FetchRow()) { $i = ++$i; array_push($result["result"], $array[termino_preferido] ? $array[termino_preferido] : $array[tema]); } return $result; }
/** * Retorna los datos, acorde al formato de autocompleter */ function getData4Autocompleter($searchq, $type = 1) { $sql = $type == 1 ? SQLstartWith($searchq) : SQLbuscaTerminosSimple($searchq, "15"); $arrayResponse = array("query" => $searchq, "suggestions" => array(), "data" => array()); while ($array = $sql->FetchRow()) { array_push($arrayResponse["suggestions"], $array["tema"]); array_push($arrayResponse["data"], $array["tema_id"]); } return json_encode($arrayResponse); }