本文介紹了如何從數(shù)據(jù)庫(kù)中的mysqli輸入中搜索值的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我想在使用值的第一個(gè)字符時(shí)顯示我的數(shù)據(jù)庫(kù)值.讓我用我的網(wǎng)站來(lái)描述它我有一個(gè)帶有主頁(yè)輸入的網(wǎng)站,其中用戶(hù)鍵入輸入作為火車(chē)號(hào).我需要那個(gè)用戶(hù)類(lèi)型的火車(chē)號(hào).他從我存儲(chǔ)的數(shù)據(jù)庫(kù)中獲得了火車(chē)名稱(chēng).
解決方案
檢查此代碼.我認(rèn)為它會(huì)對(duì)您有所幫助
<頭><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>PHP、jQuery搜索演示</title><link rel="stylesheet" type="text/css" href="my.css"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><script type="text/javascript">$(document).ready(function () {$("輸入").keyup(function () {$('#results').html('');var searchString = $("#search_box").val();var data = 'search_text=' + searchString;如果(搜索字符串){$.ajax({類(lèi)型:POST",網(wǎng)址:'search.php',數(shù)據(jù):數(shù)據(jù),數(shù)據(jù)類(lèi)型:'文本',異步:假,緩存:假,成功:功能(結(jié)果){$('#results').html(result);//window.location.reload();}});}});});頭部><身體><div id="容器"><div style="margin:20px auto; text-align: center;"><form method="post" action="do_search.php"><input type="text" name="search" id="search_box" class='search_box'/><input type="submit" value="Search" class="search_button"/><br/></表單>