jQuery自动完成MySQL和PHP结果don';我没有出现
我对jQuery中的插件有一个问题,它没有向我显示任何结果。我不知道我在哪里犯的错 这就是我的newJob.php:jQuery自动完成MySQL和PHP结果don';我没有出现,php,jquery,mysql,jquery-ui-autocomplete,Php,Jquery,Mysql,Jquery Ui Autocomplete,我对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="s
<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>
客户名称:
$(函数(){
//自动完成
$(“#客户名称”).autocomplete({
来源:“searchCustomer.php”,
最小长度:1
});
});
My 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
}
?>
怎么了?谢谢你的帮助 我相信MySQL不允许列和表名之间有空格。您确定使用了正确的列名和表名吗?不确定
选择客户名
如果字段/列可以包含空格,或者如果您的意思是选择客户,名称
与客户和名称相同。我假设$\u POST['customerName')
为空,因为您没有发布任何内容,因此,您的查询永远不会实际执行。Customer Name
和customerName
-$row['customerName'代码>?我很困惑,我不应该这样。我建议您将列名更改为Customer\u name
,并将您的查询更改为反映该更改。我的意思是“Customer name”,但我现在将其更改为Customer\u name