所以我正在研究这个项目,我正在使用jQuery自动完成来显示来自mysql数据库的搜索结果.搜索结果是从具有产品图像的数据库中提取的产品名称.我如何能够显示产品图像,如下图所示?
这是我的jQuery自动完成页面:
<script>
$( "#birds" ).autocomplete({
source: "search.php",
minLength: 2,
select: function( event, ui ) {
log( ui.item ? "Selected: " + ui.item.value + " aka " + ui.item.label :
"Nothing selected, input was " + this.actor );
window.location.href = './products/' + ui.item.productid;
//window.location.href = 'product_display.php?id=' + ui.item.value;
// document.testForm.action = "pretravel.php?id="+ui.item.value;
//document.testForm.submit();
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
search.php中
<?php
include 'dbconnector.php';
// Sanitise GET var
if(isset($_GET['term']))
{
$term = mysql_real_escape_string($_GET['term']);
// Add WHERE clause
//$term="Apple";
$query = "SELECT `productid`, `productname` …
Run Code Online (Sandbox Code Playgroud)