..
<?php

require("../globals.php") ;
$connection = mysql_connect($hostName,$userName,$password)//("localhost",root)
or die ("Nemohu otevřít server");

$db = mysql_select_db("$databaseName", $connection) or die //("prace"),
              ("Nemohu otevřít vybrat databázi");




if ($submit) {

  // here if no ID then adding else we're editing

  if ($idtyp) {

    $sql = "UPDATE typ SET
            Typ='$Typ',
            Typn='$TypN'

            WHERE idtyp=$idtyp";

  } else {

  $sql = "INSERT INTO  typ
          (Typ, TypN)
          VALUES
         ('$Typ', '$TypN')";

  }

  // run SQL against the DB

  $result = mysql_query($sql);

echo "Record updated/edited!<p>";

} elseif ($delete) {

        // delete a record

    $sql = "DELETE FROM typ WHERE idtyp = $idtyp";

    $result = mysql_query($sql);

    echo "$sql Záznam byl vymazán!<p>";

} else {

  // this part happens if we don't press submit

  if (!$idtyp) {

    // print the list if there is not editing

    $result = mysql_query("SELECT * FROM typ order by typ",$connection);

     echo"<TABLE border=1 cellspacing=0 cellpadding=0 width=100%>
      <TH>Typ </TH>
    <TH>Typ německy</TH>
    <TH>Výmaz</TH>


     ";


    while ($myrow = mysql_fetch_array($result)) {
echo"<tr><td>";
      printf("<a href=\"%s?idtyp=%s\"><center>%s</center></a></td>

 <td><center>%s</center></td>

  </a> \n",

 $PHP_SELF, $myrow["idtyp"], $myrow["Typ"],$myrow["TypN"]);
echo"</td><td>";
          printf("<a href=\"%s?idtyp=%s&delete=yes\"><center><small>(VYMAZAT)</center></small></a>",
          $PHP_SELF, $myrow["idtyp"]);
    }
  echo"</td></tr></table>";
  }

  ?>

  <P>
  <a href="<?php echo $PHP_SELF?>">ADD A RECORD</a>
  <P>
  <form method="post" action="<?php echo $PHP_SELF?>">
  <?php
  if ($idtyp) {
    // editing so select a record
    $sql = "SELECT * FROM typ WHERE idtyp = $idtyp";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    $idtyp = $myrow["idtyp"];
    $Typ = $myrow["Typ"];
    $typn = $myrow["TypN"];

    // print the idy for editing

    ?>
    <input type=hidden name="idtyp" value="<?php echo $idtyp ?>">
    <?php
  }

  ?>
<a name ="odkaz"></a>
<table cellspacing=0 cellpadding=0>


<tr>
<td valign=middle><strong>Typ výrobku</strong></td>
<td valign=top><input type="Text" name="Typ" value="<?php echo
    $Typ?>"size=50>
</td></tr>



<tr>
<td valign=middle><strong>Typ německy</strong></td>
<td valign=top><input type="Text" name="TypN" value="<?php echo
    $typn?>"size=50>
</td></tr>


  <input type="Submit" name="submit" value="Přidej nebo uprav záznam">

  </form></table>
 <?php
 }

 ?>


