<!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=utf-8" />
<script src="../jquery-1.11.2.min.js"></script>
<title>无标题文档</title>
<style type="text/css">
*{ margin:0px auto; padding:0px}
.l{ width:200px; height:30px; text-align:center; line-height:30px; vertical-align:middle; border-bottom:1px solid #60F}
</style>
</head>
<body>
<br />
<div style="width:200px; height:35px;border:2px solid #60F"><input style="width:196px; height:31px;" type="text" id="name" /></div>
<div id="list" style="width:200px; border:2px solid #60F">
</div>
<script type="text/javascript">
$("#name").keyup(function(){
var n = $(this).val();
if(n!="")
{
$.ajax({
url:"aachuli.php",
data:{n:n},
type:"POST",
dataType:"TEXT",
success: function(data){
var sz = data.split("|");
var str = "";
for(var i=0;i<sz.length;i++)
{
str = str+"<div class='l'>"+sz[i]+"</div>";
}
$("#list").html(str);
}
});
}
else
{
$("#list").html("");
}
})
</script>
</body>
</html>
<?php
$name=$_POST["n"];
include("../DBDA.class.php");
$db=new DBDA();
$sql="select areaname from chinastates where areaname like '%{$name}%'";
echo $db->StrQuery($sql);