如何匹配输入类型值和 mysql 数据库行值?如果两个值不应该相互匹配,那么echo A Message
?
主页
$(function() {
$( "#textname" ).autocomplete({
source: "data.php",
minLength: 1
});
});
</script>
<div class="ui-widget">
<label for="Name">Name: </label>
<input id="textname" class="textname"/>
</div>
数据页
<?php
$conn = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("edgesoft", $conn) or die(mysql_error());
$q = strtolower($_GET["term"]);
$return = array();
$query = mysql_query("select * from customers where cname like '%$q%'") or die(mysql_error());
while ($row = mysql_fetch_array($query)) {
array_push($return,array('label'=>$row['cname'],'value'=>$row['cname']));
}
echo(json_encode($return));
if(json_encode($return))
{
echo "test";
}
?>