title: EDIT Single ROW in database from html form
body: <p>I want to edit single line not all, but now i add ID and now he do nothing, nothing change :(, before i give him ID, they edit all rows.</p>
  
  <p>variables </p>
  
  <pre><code>$titletxt = ($_POST['title_txt']);
  $value1 = ($_POST['value1_txt']);
  $value2 = ($_POST['value2_txt']);
  $ID = ($_POST['id']);
  
  &lt;?php
  if( isset($_POST['edit']) ){
      $con=mysqli_connect("localhost","root","","hanza");
      if (mysqli_connect_errno()){
          echo "Neizdevas savienoties ar MySQL: " . mysqli_connect_error();
      }
      $sql="UPDATE dati SET title='$titletxt', value1='$value1', value2='$value2' WHERE ID = '$ID'";
      if (!mysqli_query($con,$sql)){
          die('Error: ' . mysqli_error($con));
      }
      echo '&lt;script&gt;
      alert(" Ieraksts ir veiksmigi labots! ");
  
      window.location.href = "index.php";
      &lt;/script&gt;';
      mysqli_close($con);
  }
  ?&gt;
  </code></pre>
  
  <p>That code is from form and i show results from database.</p>
  
  <pre><code>&lt;form action="insert.php" method="post"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td class="td_opt"&gt;Title&lt;/td&gt;
              &lt;td class="td_opt"&gt;Value 1&lt;/td&gt;
              &lt;td class="td_opt"&gt;Value 2&lt;/td&gt;
              &lt;td class="td_opt"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;input type="hidden" name="id" value=""&gt;
              &lt;td class="td_title"&gt;&lt;input type="text" name="title_txt" value=""&gt;&lt;/td&gt;
              &lt;td class="td_value"&gt;&lt;input type="text" name="value1_txt" value=""&gt;&lt;/td&gt;
              &lt;td class="td_value"&gt;&lt;input type="text" name="value2_txt" value=""&gt;&lt;/td&gt;
              &lt;td class="td_value"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php
              $con=mysqli_connect("localhost","root","","hanza");
              if (mysqli_connect_errno()) {
                  echo "Neizdevas 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;input type='hidden' value='" . $row['ID'] . "'&gt;";
                  echo "&lt;td&gt;&lt;input type='text' value='" . $row['title'] . "'&gt;&lt;/td&gt;";
                  echo "&lt;td&gt;&lt;input type='text' value='" . $row['value1'] . "'&gt;&lt;/td&gt;";
                  echo "&lt;td&gt;&lt;input type='text' value='" . $row['value2'] . "'&gt;&lt;/td&gt;";
                  echo "&lt;td&gt;&lt;button name='edit' class='frm_btns'&gt;Edit&lt;/button&gt;&lt;/td&gt;";
                  echo "&lt;/tr&gt;";
              }
              mysqli_close($con);
          ?&gt;
      &lt;/table&gt;
      &lt;div class="atp"&gt;&lt;/div&gt;
      &lt;button class="frm_btns" name="pievienot"&gt;New&lt;/button&gt; // add new row
  &lt;/form&gt;
  </code></pre>
  
  <p>Maybe some variable is not corect to edit only one row?</p>