0

データベースから抽出された関連名のリストを時系列でロードすることを目的とする選択ドロップダウンリストを作成しました

ドロップダウン リストから協会名を選択するたびに、対応する住所、郵便番号、および協会の市区町村をテキスト フィールドに表示できるようにしたいと考えています。

以下のコードを使用すると、ドロップダウン リストから選択した関連付け名と関連付けの ID 番号を取得できますが、その後、他の情報 (住所、郵便番号など) を抽出する方法がわかりません。 .)。

どんなアイデアでも大歓迎です、そして/または例は大歓迎です、前もって感謝します

<?php
$entry_array_ass = array ();
$entry_array_ass[0]['denomination'] = "";  // default value

$sql = "select id_association, denomination, adresse, numero, localite from association     
ORDER BY denomination";

$rs = mysql_query($sql) or die("Erreur de requ&ecirc;te : $sql");;

while($row=mysql_fetch_array($rs))
{
 extract($row);
 $entry_array_ass[$row[0]] = array ('denomination' => $row[1], 'adresse' => $row[2]);                         
}

$return_select = '<select name="list_ass" style="font-family : Verdana; font-size : 
10pt;  width:50" onchange="list_ass_handler()">';

if ( is_array ( $entry_array_ass ) ) 
{
// $K contains the key pointing to the id_association number
// $V is the array containing the denomination of each association

foreach ( $entry_array_ass as $K => $V ) 
{                             
      $return_select .= '<option value="' . $K . '"';

      // $return_select contains the list of all associations
         $return_select .= ">{$V['denomination']}</option>";              
}
}

$return_select .= "</select>";

// Display the association name
echo '<input type="hidden" name="location" id="entry_location">' . $return_select; 

// Display the ID number of the association
echo '<input type="hidden" name="id_location" id="entry_id_location">';                     
?>
4

0 に答える 0