update.php
<script type="text/javascript">
$(function() {
$( "#items" ).autocomplete({
source: 'searchforitem.php'
});
});
</script>
<div class="ui-widget"><input id="items" name="itemname" placeholder="Search Item here"></div>
searchforitem.php
<?php include_once 'dbcontroller.php';
//get search term
$searchTerm = $_GET['term'];
//get matched data from skills table
$query = $mysqli->query("SELECT * FROM item,category,brand WHERE ((Partno LIKE '%".$searchTerm."%') OR (Description LIKE '%".$searchTerm."%') OR (Cname LIKE '%".$searchTerm."%') OR (Cname LIKE '%".$searchTerm."%')) AND ((item.Bno=brand.Bno) AND (item.Cno=category.Cno)) ORDER BY Partno ASC");
while ($row = $query->fetch_assoc()) {
$data[] = $row['Partno']." ".$row['Bname']." ".$row['Description'];
}
//return json data
echo json_encode($data);
?>
现在我想要的是我希望输入id="items"
具有值零件,但是可以看到下拉列表中的所有数据。
希望我能告诉你我想做什么。
任何帮助都会很棒
我在Searchforitem.php做什么?
我正在显示项目表中的所有数据,其中术语与SKU,名称,描述,品牌名称或类别名称匹配
现在我正在显示所有数据,但我希望输入值仅为&#34; Partno&#34; 这可能吗?
答案 0 :(得分:1)
您需要为partno创建具有键“value”的关联数组才能完成此任务。
while ($row = $query->fetch_assoc()) {
$data[] = [ "value" => $row['Partno'] , "bname" => $row['Bname'] , "description" => $row['Description']];
}
答案 1 :(得分:0)
我需要使用关联数组和Key&#34; value&#34;对于partno和&#34;标签&#34;对于我需要显示的所有信息,这是代码..
WITH cte AS(
SELECT customerNumber, attributeid , max(Cust_date) AS Cust_date
FROM MyTable
WHERE Attributeid in (53,54,55)
GROUP BY customerNumber, attributeid
)
SELECT a.*
FROM MyTable AS a
JOIN cte AS b
ON b.customerNumber = a.customerNumber
AND b.attributeid = a.attributeid
AND b.Cust_date = a.Cust_date
感谢Faiz99提供关联数组的概念并使用Key&#34; value&#34;