views:

35

answers:

1

Hello everyone,

I have the following db-retrieve which results in the Listbox I like to have. But I need $desc2 to be shown under the listbox in a separate field and it must change its content when the user clicks on an other item in the list:

Here is the retrieve which works:

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>";

As I'm now searchin for some time, but didn't found something, hopefully someone here could help me.

The code for the side is in php.

Thanks in advance.

A: 

You would have to store $desc2 to a temporary variable in the loop, and use the temporary variable after the select to show the temporary variable.

I would however, point out that in general, this is probably the wrong way of going about this code, and that your problem is deeper in your implementation :)

devians