我有一个表格可以获取航班的“发件人”字段:
<p><label ></label><input type='text' name='nereden' value='' class='auto' id = "1"></p>
我有自动完成方法:
$return_arr = 数组();
if ($conn)
{
$ac_term = "%".$_GET['term']."%";
$query = "SELECT table2.CityName, table2.CountryName, table2.AirportName FROM table2 where CityName like :term";
$result = $conn->prepare($query);
$result->bindValue(":term",$ac_term);
$result->execute();
/* Retrieve and store in array the results of the query.*/
for($i = 0; $i < 3; $i++) {
if ($row = $result->fetch(PDO::FETCH_ASSOC) ) {
array_push($return_arr, array('label' => $row['CityName'], 'value' => $row['CityCode']));
array_push($return_arr, array('label' => $row['CityName'] + " " + $row['AirportName'], 'value' => $row['CityCode']));
}
}
当我排除 + " " + $row['AirportName'] 时,此代码工作正常,但我希望此自动完成功能显示类似以下内容作为虚拟示例:Athens, Athens Airport
行名,连接都是正确的。我怎样才能做到这一点?
谢谢