<?
/*----------------------------------------------------------------------------*/
/*-- Program   :     Mediartec Webshop 1.0                                    */
/*-- Author    :     Markus@Kaatze.de, Mediartec GmbH                         */
/*-- Created on:     10 September                                              */
/*-- Purpose   :     Automatisches Erzeugen einer Editiermaske für Tabellen   */
/*----------------------------------------------------------------------------*/
/*-- Change History                                                           */
/*-- DATE         Who               What                                      */
/*----------------------------------------------------------------------------*/
/*-- 10-10-01     mKaatze           Creation.                                 */
/*----------------------------------------------------------------------------*/


  $res=send_sql($sql);
  $anz=mysql_num_fields($res);
  echo "<table border=1 cellpadding='1' cellspacing='1' align=center>";

    $row  =  mysql_fetch_array($res,MYSQL_NUM);
    for ($i=0;$i<$anz;$i++)
    {
      $name=mysql_field_name($res,$i);
      echo "<tr>";
        echo "<th align=left width=150px>";
          echo $name;
        echo "</th>";
        echo "<td>";
          if ($name=="mwst")
          {
            echo "<select name='mwst' size='1'>";
            if ($row[$i]==2)
            {
              echo "<option value=2>$mwst2 %";
              echo "<option value=1>$mwst1 %";
            }
            else
            {
              echo "<option value=1>$mwst1 %";
              echo "<option value=2>$mwst2 %";
            }
            echo "</select>";
          }
          elseif ($name=="Lieferant_id")
          {
             $res2=send_sql("select lieferant_ID, Name from Lieferanten");
             echo "<select name='$name' size=1>";
             while ($row2  =  mysql_fetch_array($res2,MYSQL_NUM))
             {
               echo "<option value=$row2[0]>$row2[1]</option>";
             }
             echo "</select>";
          }
          elseif ($name=="ArtGrNr")
          {
             $res2=send_sql("select * from Artikelgruppe");
             echo "<select name='$name' size=1>";
             while ($row2  =  mysql_fetch_array($res2,MYSQL_NUM))
             {
               echo "<option value=$row2[0]>$row2[0]: $row2[1]</option>";
             }
             echo "</select>";
          }
          else
            echo "<input type='Text' name='$name' value='$row[$i]' size='40'>";
        echo "</td>";
      echo "</tr>";
    }
     echo "<tr>";
        echo "<th>";
          echo "<input type=\"submit\" value=\"OK\">&nbsp;&nbsp;&nbsp;&nbsp;";
        echo "</th>";
        echo "<td>";
          echo "<input type=\"reset\" value=\"Abbruch\">";
        echo "</td>";
      echo "</tr>";
  echo "</table>";
?>