Хорошо, я перехожу к следующему этапу с JQuery, и я несколько раз успешно использовал автозаполнение, но только с использованием одной таблицы из MYSQL.Теперь я использую его и пытаюсь выполнить запрос JOIN.Запрос MYSQL работает нормально, когда я меняю LIKE :term
на = 1
(например, номер клиента) в MYSQL, но когда я пытаюсь выполнить приведенный ниже запрос, я ничего не получаю, а не просто ошибки.Есть какие-нибудь предложения?
::: ЭТО СТРАНИЦА ПОИСКА :::
<?php require '../_includes/jq.inc.php';?>
<link href="../_stylesheets/UPDATE.Customer.css" rel="stylesheet" type="text/css">
<html>
<head>
<script type="text/javascript">
$(function() {
$('#CustomersCustomer_ID').val("");
$('#CustomersCompanyName').val("");
$('#CustomerDetailsDiscount').val("");
$('#CustomerNotesCustNotes').val("");
$("#searchterm").autocomplete({
source: "UPDATE.Customer.SEARCH.QUERYTEST.php",
minLength: 1,
select: function(event, ui) {
$('#CustomersCustomer_ID').val(ui.item.CustomersCustomer_ID);
$('#CustomersCompanyName').val(ui.item.CustomersCompanyName);
$('#CustomerDetailsDiscount').val(ui.item.CustomerDetailsDiscount);
$('#CustomerNotesCustNotes').val(ui.item.CustomerNotesCustNotes);
}
});
});
</script>
</head>
<body>
<form action="<?php echo $PHP_SELF;?>" method="post">
SEARCH:<p class="ui-widget">
<input type="text" id="searchterm" size="60" onClick="this.form.reset()"/>
</form>
<form>
CustomersCustomer_ID<br>
<input name="CustomersCustomer_ID" type="text" id="CustomersCustomer_ID" size="10">
<br>
CustomersCompanyName<br>
<input name="CustomersCompanyName" type="text" id="CustomersCompanyName" size="20">
<br>
CustomerNotesCustNotes<br>
<textarea name="CustomerNotesCustNotes" id="CustomerNotesCustNotes" cols="20" rows="3"></textarea>
<br>
CustomerDetailsDiscount<br>
<input name="CustomerDetailsDiscount" type="text" id="CustomerDetailsDiscount" size="5">
</form>
</body>
</html>
ЭТО СТРАНИЦА ЗАДАНИЯ ЗАПРОСА // ВЛЕВО ИЗ ИНФОРМАЦИИ О СОЕДИНЕНИИ
if ($conn)
{
$ac_term = "%".$_GET['term']."%";
$query = "SELECT
Customers.Customer_ID,
Customers.CompanyName,
CustomerDetails.Discount,
CustomerNotes.CustNotes,
CONCAT_WS(' ', Customers.Customer_ID, Customers.CompanyName, CustomerDetails.Discount, CustomerNotes.CustNotes) AS DisplayName
FROM Customers
JOIN CustomerDetails USING (`Customer_ID`)
JOIN CustomerNotes USING (`Customer_ID`)
WHERE `Customer_ID` LIKE :term
OR Customers.CompanyName LIKE :term
OR CustomerDetails.Discount LIKE :term
OR CustomerNotes.CustNotes LIKE :term
";
$result = $conn->prepare($query);
$result->bindValue(":term",$ac_term);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$row_array['value'] = $row['DisplayName'];
$row_array['CustomersCustomer_ID'] = $row['Customers.Customer_ID'];
$row_array['CustomersCompanyName'] = $row['Customers.CompanyName'];
$row_array['CustomerDetailsDiscount'] = $row['CustomerDetails.Discount'];
$row_array['CustomerNotesCustNotes'] = $row['CustomerNotes.CustNotes'];
array_push($return_arr,$row_array);
}
}
$conn = null;
echo json_encode($return_arr);
?>