2010-01-21 122 views
0

我有以下db-retrieve,導致我喜歡的列表框。 但我需要$ DESC2在一個單獨的字段列表框下顯示,當用戶點擊列表中的其他項目也必須改變它的內容:html listbox在列表框外部顯示額外的字段中的額外txt

這裏是檢索的工作原理:

echo "<form action=\"admin.php\" method=\"post\">"; 
echo "Industry:<SELECT name=\"industry\" size=\"10\">"; 
$result=sql_query("SELECT cat, title, desc, parentid 
        FROM industries 
        WHERE language='english'"); 
while(list($cid2, $ctitle2, $desc2, $parentid2) = sql_fetch_row($result)) { 
    if ($cid2==$userindustry) { 
     $sel = "selected"; 
    } else { 
     $sel = ""; 
    } 
    if ($parentid2!=0) $ctitle2=getparentindustry($parentid2,$ctitle2); 
    echo "<option value=\"$cid2\" $sel>$ctitle2</option>"; 
} 
echo "</SELECT> 
     <br>$desc2<br> # place to show description of list item 
     <input type=\"hidden\" name=\"op\" value=\"save\"> 
     <input type=\"submit\" value=\"Go\"></form><br>"; 

由於我現在搜索了一段時間,但沒有發現什麼,希望有人在這裏可以幫助我。

這邊的代碼是在php中。

在此先感謝。

回答

0

您必須將$ desc2存儲到循環中的臨時變量中,並在select之後使用臨時變量來顯示臨時變量。

但是,我會指出,一般來說,這可能是關於此代碼的錯誤方法,並且您的問題在您的實現中更深入:)