안녕하세요, jquery 자동 완성을 사용하는 입력 텍스트에 대한 코드를 작성하지만 jquery 자동 완성은 PHP 코드를 사용하여 mysql에서 데이터를 가져올 수 없습니다.
내 코드가 잘못 되었나요?
아래 내 자바 스크립트 코드JQuery 자동 완성은 데이터베이스에서 값을 가져올 수 없습니다.
<link href="_style/css/smoothness/jquery-ui-1.8.17.custom.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="_scripts/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="_scripts/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript">
$(function() {
$("#autocomplete").autocomplete({
source: "search.php",
minLength: 2,
select: function(event, ui) {
log(ui.item ?
"Selected: " + ui.item.value + " aka " + ui.item.id :
"Nothing selected, input was " + this.value);
}
});
});
</script>
<body>
<input type="text" id="autocomplete" />
</body>
이 내 PHP 코드입니다 : 내 코드 문제를 해결하기 위해
<?php
include "Connect.php";
$term = trim(strip_tags($_GET['term']));
$qstring = "SELECT pName as value,pID FROM patient WHERE pName LIKE '%".$term."%'";
$result = mysql_query($qstring, $connection);//query the database for entries containing the term
while ($row = mysql_fetch_array($result))//loop through the retrieved values
{
$row['pName']=htmlentities(stripslashes($row['pName']));
$row['pID']=(int)$row['pID'];
$row_set[] = $row;//build an array
}
echo json_encode($row_set);//format the array into json data
?>
도움! 내가 거기에 아무 잘못이 JQuery와 기능에 있지만 여기에 내가 당신의 PHP 잘못 무엇을보고 있는지 알고 해달라고
PHP 스크립트에서 데이터를 반환합니까? – tftd
자동 완성 편집 텍스트없이 내 PHP 코드를 확인하고 PHP 코드가 제대로 작동하는지 확인하십시오! –