0
我有一個具有以下字段的格式: 公司名稱, 地址, 市AUSU jQuery的Ajax的自動提示的多個值
使用AUSU jQuery的自動提示腳本我能基礎上,來填充地址字段搜索在公司領域完成,但我似乎無法完成的事情也是以適當的價值填充城市領域。所有數據都存儲在一個mysql數據庫中。
我已經得到儘可能地址和城市填充地址字段,但我需要這兩個值進入各自的領域(shiptoaddress和shiptocity)。
有什麼建議嗎?
這是我的PHP從MySQL數據庫獲取數據:
<?php
$con = mysql_connect("localhost","userid","password");
if (!$con){ die('Could not connect: ' . mysql_error()); }
mysql_select_db("dbase", $con);
$id = @$_POST['id']; // The id of the input that submitted the request.
$data = @$_POST['data']; // The value of the textbox.
if ($id && $data)
{
if ($id=='clients')
{
$query = "SELECT shiptoaddress,company, shiptocity
FROM Clients
WHERE company LIKE '%$data%'
LIMIT 5";
$result = mysql_query($query);
$dataList = array();
while ($row = mysql_fetch_array($result))
{
$toReturn = $row['company'];
$dataList[] = '<li id="' .$row['shiptoaddress'] .$row['shiptocity'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>';
}
if (count($dataList)>=1)
{
$dataOutput = join("\r\n", $dataList);
echo $dataOutput;
}
else
{
echo '<li><a href="#">No Results</a></li>';
}
}
}
?>
這是HTML表單代碼的一部分:
<script>
$(document).ready(function() {
$.fn.autosugguest({
className: 'ausu-suggest',
methodType: 'POST',
minChars: 2,
rtnIDs: true,
dataFile: 'data.php'
});
});
</script>
</head>
<body>
<div id="wrapper">
<form action="index.php" method="get">
<div class="ausu-suggest">
<input type="text" size="100" value="" name="clients" id="clients" autocomplete="off" />
<input type="text" size="100" value="" name="shiptoaddress" id="shiptoaddress" autocomplete="off"/>
<input type="text" size="100" value="" name="shiptocity" id="shiptocity" autocomplete="off"/>
</div>
</form>