<html>
<head>
<?
//Anfangszustand
$a=$b=$c="";

if (isset($_GET['knopf']))
{
   if (isset($_GET['obst']))
   {
      $wert=$_GET['obst'];
      $len=sizeof($wert);

      for ($i=0;$i<$len;$i++)
      {
         switch ($wert[$i])
         {
            case "apfel":
               echo "Sie haben Apfel gewählt.<br>";
               $a="selected";
               break;
            case "birne":
               echo "Sie haben Birne gewählt.<br>";
               $b="selected";
               break;
            case "banane":
               echo "Sie haben Banane gewählt.<br>";
               $c="selected";
               break;
         }
      }
   }
   else
      echo "Sie haben nichts ausgewählt.<br>";
}
?>
</head>
<body>
<h2>Mehrfachauswahlliste:</h2>
<form action="./gui5.php" method="get">
<select name="obst[]" multiple="multiple" size="3">
<option value="apfel"<?=$a?> >Apfel</option>
<option value="birne"<?=$b?> >Birne</option>
<option value="banane"<?=$c?> >Banane</option>
</select>
<input type="submit" name="knopf" value="Aktion">
</form>
</body>
</html>