Привет, я пишу код для входного текста, который использует автозаполнение jquery, но автозаполнение jquery не может извлечь данные из mysql, используя мой php-код.
что не так в моем коде?
ниже мой код JavaScript
<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
?>
помогите мне исправить мои проблемы с кодом!