Ec (2); php + ajax code 1 in the google drop-down box. Here, the php code & lt ;? Phpheader (Content-Type: texthtml; charsetutf-8); require (.... admin1_dedb_conf.php); if ($ _ POST [add]) {& nbsp; $ keywordtrim ($ _ script ec (2); script
Php + ajax is similar to google drop-down box code 1. php code here
Header ('content-Type: text/html; charset = UTF-8 ');
Require ('../admin/include/db_conf.php ');
If ($ _ POST ['add']) {
$ Keyword = trim ($ _ POST ['keyword']);
If (empty ($ keyword )){
Header ("LOCATION: suggest.html ");
Exit;
}
$ Db = db_connect ();
$ Db-> query ("set names 'gb2312 '");
$ SQL = "select * from suggest where keyword = '$ keyword '";
If ($ db-> query ($ SQL)-> num_rows> 0 ){
Header ("LOCATION: suggest.html ");
Exit;
}
$ Num = rand (15,200 8 );
$ SQL = "insert into suggest values (NULL, '$ keyword', $ num )";
$ Db-> query ($ SQL );
$ Db = NULL;
Header ("LOCATION: suggest.html ");
Exit;
}
$ Keyword = $ _ POST ['keyword'];
If (empty ($ keyword )){
Echo 'null ';
Exit;
}
$ Db = db_connect ();
$ Db-> query ("set names 'utf8 '");
$ SQL = "select * from suggest where keyword REGEXP '^ $ keyword' order by id desc limit 0, 15 ";
$ Result = $ db-> query ($ SQL );
If ($ result-> num_rows <1 ){
Echo 'null ';
Exit;
}
$ Arr = array ();
While ($ rows = $ result-> fetch_object ()){
$ Keyword = $ rows-> keyword;
$ Arr [] = "['$ keyword',' $ rows-> num ". iconv ('gb2312', 'utf-8', 'result '). "']";
}
$ Arr = '['. implode (',', $ arr). ']';
Echo $ arr;
?>