0

我在 jQuery 中的插件有问题,它没有显示任何结果。我不知道我在哪里犯了错误?

那是我的newJob.php:

<form method="post" action="newJob.php">
<span>Customer Name:<input type="text" id="customerName" name="customerName"></span><br>
<input type="submit" name="submitJob" value="Create Job" >
</form>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery-ui.js"></script>
<script type="text/javascript" src="../js/startDate.js"></script>
<script type="text/javascript">
  $(function() {
     //autocomplete
     $("#customerName").autocomplete({
       source: "searchCustomer.php",
       minLength: 1
     });                
  });
</script>

我的 searchCustomer.php:

<?php
include('classes.php');

$obj = new CompanyDatabase;
$obj->connect_db();
$obj->select_db();

if (isset($_POST['customerName'])) {
$query = $_POST['customerName'];
$sql = mysql_query ("SELECT `Customer Name` FROM `job` WHERE `Customer Name` LIKE \"%".$query."%\"");
$array = array();
while ($row = mysql_fetch_assoc($sql)) {
    $array[] = $row['customerName'];
}
echo json_encode ($array); //Return the JSON Array
}
?>

它出什么问题了?谢谢你的帮助!

4

1 回答 1

0

我相信 MySQL 不允许列名和表名在名称之间有空格。你确定你使用了正确的列名和表名吗?

于 2013-10-28T17:16:59.473 回答