0

フライトの「From」フィールドを取得するフォームがあります。

<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

行名、接続はすべて正しいです。これどうやってするの?

ありがとうございました

4

1 に答える 1

0

PHP では、文字列連結演算子.であり、 ではありません+

array_push($return_arr, array('label' => $row['CityName'] . " " . $row['AirportName'], 'value' => $row['CityCode']));
于 2013-06-20T19:07:05.820 に答える