저는 부트 스트랩에 새로운 기능이있어서 연락처를 검색 할 때 내 mysql 데이터베이스에서 3 가지 값을 반환하는 미리보기 드롭 다운을 만들고 싶습니다. "연락처 이름"텍스트 상자에 이름을 지정하고 모든 노력을 사전에 감사에게 접촉 식 이름의 정보 - 전화 번호 -email 주소로 많은 3 편집 상자를 채워Twitter bootstrap typeahead 여러 값을 반환하고 편집 상자를 채우십시오.
이 코드는 그 전 그것을 하나의 값을 반환하려고 모든 tree 값을 반환하기 위해 수정해야합니다 이제 연락처 이름을 검색하려고하면 함께 반환됩니다. 제대로없는 질문은 물어하지만 난 내가 제대로 이해하고있어 경우, 당신은을 채울 다시 있지만 수없는 결과를 얻고 난
enter code here
**php page: Customer.php**
-------------------------------------------
<?php
$host = "localhost";
$uname = "root";
$pass = "";
$database = "db34218";
$connection=mysql_connect($host,$uname,$pass) or die("connection in not ready <br>");
$result=mysql_select_db($database) or die("database cannot be selected <br>");
if (isset($_REQUEST['query'])) {
$query = $_REQUEST['query'];
$sql = mysql_query ("SELECT ContactName, Telephone, Email FROM customer WHERE ContactName LIKE '%{$query}%'");
$array = array();
while ($row = mysql_fetch_assoc($sql)) {
$array[] = $row['ContactName'];
}
echo json_encode ($array); //Return the JSON Array
}
?>
**html and java page and some php: Customersearch.php**
------------------------------------------------
<body>
.
.
.
<div class="row-fluid">
<div class="span4">
<label>ContactName </label>
<input type="text" name="ContactName" value="<?php echo $row_Recordset_QuoteCustomer['ContactName']?>" data-provide="typeahead" class="typeahead input-xlarge" autocomplete="off">
</div>
<div class="span2">
<label>Telephone </label>
<input type="text" name="Telephone" value="<?php echo htmlentities($row_Recordset_QuoteCustomer['Telephone'], ENT_COMPAT, 'utf-8'); ?>" class="span12">
</div>
<div class="span2">
<label>Email </label>
<input type="text" name="Email " value="<?php echo htmlentities(row_Recordset_QuoteCustomer['Email '], ENT_COMPAT, 'utf-8'); ?>" class="span12">
</div>
.........
.
.
.
.
.
.
<script src="../js/jquery.js"></script>
<script src="../js/bootstrap-transition.js"></script>
<script src="../js/bootstrap-alert.js"></script>
<script src="../js/bootstrap-modal.js"></script>
<script src="../js/bootstrap-dropdown.js"></script>
<script src="../js/bootstrap-scrollspy.js"></script>
<script src="../js/bootstrap-tab.js"></script>
<script src="../js/bootstrap-tooltip.js"></script>
<script src="../js/bootstrap-popover.js"></script>
<script src="../js/bootstrap-button.js"></script>
<script src="../js/bootstrap-typeahead.js"></script>
<script src="../js/SpecWorkPages/getItemsList.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('input.typeahead').typeahead({
source: function (query, process)
{
$.ajax(
{
url: 'Customer.php',
type: 'POST',
dataType: 'JSON',
data: 'query=' + query,
success: function(data)
{
console.log(data);
process(data);
}
});
}
});
})
</script>
</body>
</html>
<?php
mysql_free_result($RecordsetQuote);
mysql_free_result($Recordset_QuoteStatus);
mysql_free_result($Recordset_QuoteCustomer);
?>
Wi 누구든지 도움이 될 수있는 모든 코드가 있습니다. 아직 가지고 있지 않다면 좋은 시작을 위해 https://gist.github.com/Yavari/1891669를 보시기 바랍니다. 당신은 또한 빠른 검색과 함께 주제에 대한 다른 게시물을 확인할 수 있습니다 : http://stackoverflow.com/search?q=bootstrap+typeahead – Brian
괜찮아요 내가 내 코드를 추가 할 수있는 수정 자 내 코드 덕분에 좀 도와주세요 –