Ajax garbled text (similar to Baidu search page), online answers, heroes are free to help & nbsp; how to solve this garbled text !!! I posted all my codes: & lt ;? Php // require ('Common. inc. php '); // require ('config. inc. php '); mysql_connect ajax garbled questions (similar to Baidu search page), online answers, heroes are free to help
How can this garbled code be solved !!! I posted all the code:
// Require ('Common. inc. php ');
// Require ('config. inc. php ');
Mysql_connect ('localhost', 'root', '123 ');
Mysql_select_db ("hxy1__20100416 ");
Mysql_query ("set names gbk"); // prevents garbled characters during database interaction
Header ('content-Type: text/html; charset = gbk ');
$ QueryString = $ _ POST ['querystring'];
If (strlen ($ queryString)> 0 ){
$ SQL = "SELECT username FROM phpcms_member WHERE username LIKE '". $ queryString. "% 'limit ";
Echo $ SQL;
$ Query = mysql_query ($ SQL );
While ($ result = mysql_fetch_array ($ query ))
{
$ Value = $ result ['username'];
Echo'
'. $ Value .'';
}
}
?>
Htm:
Ajax search
Script
Function lookup (inputString ){
If (inputString. length = 0 ){
// Hide the suggestion box.
$ ('# Suggestions'). hide ();
} Else {
$. Post ("rpc. php", {queryString: "" + inputString + ""}, function (data ){
If (data. length> 0 ){
$ ('# Suggestions'). show ();
('{Autosuggestionslist'{.html (data );
}
});
}
} // Lookup
Function fill (thisValue ){
$ ('# InputString'). val (thisValue );
SetTimeout ("$ ('# suggestions'). hide ();", 200 );
}
Script
Body {
Font-family: Helvetica;
Font-size: 11px;
Color: #000;
}
H3 {
Margin: 0px;
Padding: 0px;
}
. SuggestionsBox {
Position: relative;
Left: 30px;
Margin: 10px 0px 0px 0px;
Width: 200px;
Background-color: #212427;
-Moz-border-radius: 7px;
-Webkit-border-radius: 7px;
Border: 2px solid #000;
Color: # fff;
}
. SuggestionList {
Margin: 0px;
Padding: 0px;
}
. SuggestionList li {
Margin: 0px 0px 3px 0px;
Padding: 3px;
Cursor: pointer;