<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>jquery autocomplete插件实例google baidu相关内容</title>
<script language="网页特效">
$().ready(function() {
$("#borough_name").autocomplete("ajax.php教程?action=getboroughlist", {
minchars: 2,
width: 260,
delay:0,
mustmatch:true,
matchcontains: false,
scrollheight: 220,
selectfirst:true,
scroll: true,
formatitem: function(data, i, total) {
if(data[1]=="addborough"){
return '<strong>'+data[0]+'</strong>';
}
return data[0];
}
});
}
</script>
</head>
<body>
</body>
</html>
php代码
include("conn.php");
$q = strtolower($_get["q"]);
if (!$q) return;
$datalist = mysql教程_query("select * from tn where title like '%$q%'");
$str = "";
while( $value = mysql_fetch_array( $datalist) {
$str .= $value['title']."|".$value['id']."n";
}
echo $str;