在瀏覽器的文本框中輸入數據時,它應該從數據庫中提取數據並相應顯示。 (例如:像谷歌)。 這裏是我的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