M
markeloff
Guest
hi, meine suchfunktion spuckt die umlaute nicht korrekt aus.
also statt
ä - ä
ö - ö
ü - ü
oder gebt hier einfach mal "se" in das suchfeld ein, dann seht ihrs schon.
wäre nett, wenn jemand den fehler finden würde
grüße
also statt
ä - ä
ö - ö
ü - ü
Code:
<?php
include 'kernel.php';
$q = strtolower($_GET["term"]);
if (!$q) return;
$items = array();
$it = query_into_array("SELECT team1,team2 FROM game WHERE team1 LIKE '%".mysql_real_escape_string($q)."%' OR team2 LIKE '%".mysql_real_escape_string($q)."%' ORDER BY team1");
foreach($it as $team) {
$items[$team[team1]] = "";
$items[$team[team2]] = "";
}
array_unique($items);
function array_to_json( $array ){
if( !is_array( $array ) ){
return false;
}
$associative = count( array_diff( array_keys($array), array_keys( array_keys( $array )) ));
if( $associative ){
$construct = array();
foreach( $array as $key => $value ){
if( is_numeric($key) ){
$key = "key_$key";
}
$key = "\"".addslashes($key)."\"";
if( is_array( $value )){
$value = array_to_json( $value );
} else if( !is_numeric( $value ) || is_string( $value ) ){
$value = "\"".addslashes($value)."\"";
}
$construct[] = "$key: $value";
}
$result = "{ " . implode( ", ", $construct ) . " }";
} else {
$construct = array();
foreach( $array as $value ){
if( is_array( $value )){
$value = array_to_json( $value );
} else if( !is_numeric( $value ) || is_string( $value ) ){
$value = "'".addslashes($value)."'";
}
$construct[] = $value;
}
$result = "[ " . implode( ", ", $construct ) . " ]";
}
return $result;
}
$result = array();
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
array_push($result, array("id"=>$value, "label"=>$key, "value" => strip_tags($key)));
}
if (count($result) > 11)
break;
}
echo array_to_json($result);
?>
wäre nett, wenn jemand den fehler finden würde
grüße