我如何匹配输入类型值和mysql数据库行值

how do i match input type values and mysql database row values? if both values are shouldn't be match to each others then echo A Message?

Main Page

   $(function() {
   $( "#textname" ).autocomplete({
   source: "data.php",
   minLength: 1
   });
   });
   </script>


   <div class="ui-widget">
   <label for="Name">Name: </label>
   <input id="textname" class="textname"/>
   </div>

Data Page

<?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";    
}
?>