php select下拉列表无法显示数据库中的某些数据

时间:2013-03-21 20:20:48

标签: php mysql select

我创建了一个选择下拉列表,其目的是按照从我的数据库中提取的时间顺序加载一个关联名称列表

每当我从下拉列表中选择一个关联名称时,我希望能够在文本字段中显示相应的地址,邮政编码和关联城市。

使用下面的代码,我能够从下拉列表中检索所选的关联名称以及关联的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">';                     
?>

0 个答案:

没有答案