在浏览器的文本框中输入数据时,它应该从数据库中提取数据并相应显示。 (例如:像谷歌)。 这里是我的PHP代码:在php和html上编辑文本过滤器错误
<?php
mysql_connect("localhost","root","MobixMySQL") or die(mysql_error());
mysql_select_db("filter") or die(mysql_error());
$partialStates = $_POST['partialStates'];
$states = mysql_query("SELECT name FROM list1 WHERE name LIKE "%$partialStates%"");
while($state = mysql_fetch_assoc($states)) {
echo "<div>".$state['name']."</div>";
}
?>
而下面是我的html代码:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function getStates(value){
$.post("getStates.php",{partialStates:value},function(data){
$("#results").html(data);
});
}
</script>
</head>
<body>
<input type="text" onKeyUp="getStates(this.value)" >
<div id="results"></div>
</body>
</html>
PLS建议我在哪里,我错了....!
有什么错误? –
虽然在文本字段中输入数据,但它并没有从数据库中提取数据 – naveen