0
即時通訊新的PHP和im試試這個東西幾個小時,我想顯示數組項目的選擇選項。下面的代碼:從數組列表中選擇選項
<select name="state">
<?php
$arrstate=array
(
array("AK","Alaska"),
array("AL","Alabama"),
array("AR","Arkansas"),
array("AZ","Arizona"),
array("CA","California"),
array("CO","Colorado"),
array("CT","Connecticut"),
array("DC","District of Columbia"),
array("DE","Delaware"),
array("FL","Florida"),
array("GA","Georgia"),
array("HI","Hawaii"),
array("IA","Iowa"),
array("ID","Idaho"),
array("IL","Illinois"),
array("IN","Indiana"),
array("KS","Kansas"),
array("KY","Kentucky"),
);
for($lop=0;$lop<=49;$lop++)
{
if (strtoupper($lead_info['state'])==$arrstate[$lop][0])
{
echo "<option selected=\"selected\" value=\"".$arrstate[$lop][0]."\">".$arrstate[$lop][1]."</option>\n";
}else{
echo "<option value=\"".$arrstate[$lop][0]."\">".$arrstate[$lop][1]."</option>\n";
}
}
?>
</select>
但似乎那隻能說明".$arrstate[$lop][1]."
出了什麼問題?
爲什麼不使用關聯數組? –
我想知道用戶是什麼狀態。在此頁面之前。有一個預先註冊,只有他/她的ZIP。我想根據他輸入的ZIP來顯示他/她目前的狀態。 – Kiel
你可以做一個條件選項..例如'