title: Error: Duplicate entry '0' for key 'PRIMARY'
body: <p>I can't resolve my problem, this is the error from mysql that I'm getting:</p>
  
  <p><img src="https://i.stack.imgur.com/ApW6F.jpg" alt="Error: Duplicate entry &#39;0&#39; for key &#39;PRIMARY&#39;"></p>
  
  <p>I can edit and update my data when I've got one record in the database but when I add two rows, I get the error.</p>
  
  <p>Some pictures from database</p>
  
  <p>And when I change the row, row ID goes down to 0 and that's is a problem as I can't edit other rows.</p>
  
  <p><img src="https://i.stack.imgur.com/fWGS9.jpg" alt="When i try to change row, first row ID goes down to 0">
  <img src="https://i.stack.imgur.com/HlWMt.jpg" alt="Database"></p>
  
  <p><img src="https://i.stack.imgur.com/llCOu.jpg" alt="enter image description here"></p>
  
  <pre><code>CREATE TABLE `dati` (
   `ID` int(11) NOT NULL AUTO_INCREMENT,
   `title` varchar(255) NOT NULL,
   `value1` varchar(255) NOT NULL,
   `value2` varchar(255) NOT NULL,
   PRIMARY KEY (`ID`)
  ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 PACK_KEYS=1
  </code></pre>
  
  <p>Update Code:</p>
  
  <pre><code>&lt;?php // Izlabot datus datubāzē!
  $titletxt = $_POST['title_edit'];
  $value1 = $_POST['value1_edit'];
  $value2 = $_POST['value2_edit'];
  
  if(isset($_POST['edit'])){
  $con=mysqli_connect("localhost","root","","dbname");
  if (mysqli_connect_errno())
    {
    echo "Neizdevās savienoties ar MySQL: " . mysqli_connect_error();
    }
  $sql="UPDATE dati SET ID='$ID',title= '$titletxt',value1='$value1',value2='$value2' WHERE 1";
  if (!mysqli_query($con,$sql))
    {
    die('Error: ' . mysqli_error($con));
    }
  echo '&lt;script&gt;
          alert(" Ieraksts ir veiksmīgi labots! ");
  
          window.location.href = "index.php";
      &lt;/script&gt;';
  mysqli_close($con);
  }
  ?&gt;
  </code></pre>
  
  <p>From form:</p>
  
  <pre><code>&lt;?php
              $con=mysqli_connect("localhost","root","","dbname");
              if (mysqli_connect_errno())
                {
                echo "Neizdevās savienoties ar MySQL: " . mysqli_connect_error();
                }
              $result = mysqli_query($con,"SELECT * FROM dati");
              while($row = mysqli_fetch_array($result))
                {
                echo "&lt;tr&gt;";
                    echo "&lt;td&gt;&lt;input id='titled' type='text' name='title_edit' value='" . $row['title'] . "'&gt;&lt;/td&gt;";
                    echo "&lt;td&gt;&lt;input id='value1d' type='text' name='value1_edit' value='" . $row['value1'] . "'&gt;&lt;/td&gt;";
                    echo "&lt;td&gt;&lt;input id='value2d' type='text' name='value2_edit' value='" . $row['value2'] . "'&gt;&lt;/td&gt;";
                    echo "&lt;input type='hidden' name='id' value='" . $row['ID'] . "'&gt;";
                    echo "&lt;td&gt;&lt;button name='edit' id='edit_btn' class='frm_btns' value='" . $row['ID'] . "'&gt;Edit&lt;/button&gt;&lt;/td&gt;";
                echo "&lt;/tr&gt;";
                }
              mysqli_close($con);
          ?&gt;
  </code></pre>
  
  <p>It couldn't read the value of ID, as 0 was returned.</p>