用户输入 - <input type="text" name="name">
我想取用户输入'name'并显示与该客户相关的transactionID,以及歌名和艺术家名称
我一直在使用的查询结构如下
$ q = "SELECT customers.last_name, FROM customers
LEFT JOIN transactions ON customers.customer_ID = transactions.customer_ID
LEFT JOIN songs ON songs.song_ID = transaction_details.song_ID
WHERE customers.last_name LIKE '$lname%' AND customers.first_name LIKE '$name%";
$name = $_POST['name'];
我希望它显示: transaction_ID + song_name + artist_name
有谁知道我怎么可能达到我的需要? 非常感谢。
答案 0 :(得分:0)
You can use jquery Autocomplete or go through the url :-http://jqueryui.com/autocomplete/
<script>
$(function() {
function log(message) {
$("<div>").text(message).prependTo("#log");
$("#log").scrollTop(0);
}
$("#search").autocomplete({
minLength: 1,
source: 'action.php',
})
.autocomplete("instance")._renderItem = function(ul, item) {
if (item.fname) {
if (item.photo) {
return $("<li style='padding: 0px;'' href='/user-profile?user=" + item.id + "'>")
.append("<a style='margin: 0px; display: block; width: 100%; height: 100%;' href='/user-profile?user=" + item.id + "'><img src = '{{CLIENT_ROOT_PATH}}/assests/img/profile/thumbnail-130x130/" + item.photo + "' width =30 /> " + item.fname + " " + item.lname + "</a>")
.appendTo(ul);
}
} else {
return $("<li>")
.append("<a href='#'> No result found</a>")
.appendTo(ul);
}
};
});
</script>
And here the HTML :-
<input type="text" placeholder="Search" class="form-control" id="search">
on action.php page return the required value in array form.