您好,欢迎访问一九零五行业门户网

php中兑现搜索框

php中实现搜索框
我做出来的网页效果是这样的:
怎样才能更具搜索框中的关键字在第二个页面显示搜索结果呢?
我的代码如下:
这是html的代码:
function lookup(inputstring) {
if(inputstring.length == 0) {
// hide the suggestion box.
$('#suggestions').hide();
} else {
$.post(rpc.php, {querystring: +inputstring+}, function(data){
if(data.length >0) {
$('#suggestions').show();
$('#autosuggestionslist').html(data);
}
});
}
} // lookup
function fill(thisvalue) {
$('#inputstring').val(thisvalue);
settimeout($('#suggestions').hide();, 200);
}

这是rpc.php的文件:
real_escape_string($_post['querystring']);
// is the string length greater than 0?
if(strlen($querystring) >0) {
// run the query: we use like '$querystring%'
// the percentage sign is a wild-card, in my example of countries it works like this...
// $querystring = 'uni';
// returned data = 'united states, united kindom';
// you need to alter the query to match your database.
// eg: select yourcolumnname from yourtable where yourcolumnname like '$querystring%' limit 10
$query = $db->query(select * from bbstopic where title like '%$querystring%' limit 10);
if($query) {
// while there are results loop through them - fetching an object (i like php5 btw!).
while ($result = $query ->fetch_object()) {
// format the results, im using 
for the list, you can change it.
// the onclick function fills the textbox with the result.
// you must change: $result->value to $result->your_colum
echo 'title.'\');>'.$result->title.'';
}
} else {
echo 'error: there was a problem with the query.';
其它类似信息

推荐信息