title: How to edit a database row value from a html table
body: <p>so i have a form with like 6 fields(FirstName,LastName,etc),when the users submit the form,the values are saved in a database.In another page i have a table which shows those values from database,with same 6 cols + another one which contains 2 buttons(delete and edit),the delete one works perfect,but the edit buttons has some issues</p>
  
  <p>The buttons code is this:</p>
  
  <pre><code>echo '&lt;td&gt;';
  echo '&lt;button&gt;&lt;a href="edit.php?idang='.$rand['id'].'"&gt;Modifica!&lt;/a&gt;&lt;/button&gt;';
  echo '&lt;button&gt;&lt;a href="delete.php?idang='.$rand['id'].'"&gt;Sterge!&lt;/a&gt;&lt;/button&gt;';
  echo '&lt;/td&gt;';
  </code></pre>
  
  <p>As you can see i have assigned rand id(this is the primary key for databse rows) to the var idang.</p>
  
  <pre><code>$idang=$_GET['idang'];
  if(isset($idang)) {
  $CerereSQL="SELECT * FROM `angajati` WHERE id='$idang'";
  $rezultat=mysqli_query($con,$CerereSQL);
  $rand=mysqli_fetch_assoc($rezultat);
  </code></pre>
  
  <p>I've made another variable with the global var $_GET['idang'],and then i have SELECTED the table angajati from database where the primary key from my db its equal with the primary key from the table row,which i've pushed the edit button.This method works for the delete button,and probably for the edit one too,but the real problem is that when i want to edit that row,it will link me to another page containing another form,with original values in the fields,and when i modify those fields with other values,it must change only that row,not the entire table,or the column.But i have no idea how to do that,except that it can be done with the UPDATE statement</p>
  
  <p>The rest of the code,containing the form is:</p>
  
  <pre><code>echo '&lt;table border=0 align=center cellspacing=10&gt;';    
  echo '&lt;form action="" method=post&gt;';
  
  echo '&lt;tr&gt;';
      echo '&lt;th&gt;Nume:&lt;/th&gt;&lt;td&gt;&lt;input type="text" name=nume value="';
  
          echo $num;
      echo '"&gt;&lt;/td&gt;';
  
      echo '&lt;td style=color:red&gt;';
      echo $err_nume;
      echo $err_nume1;
      echo '&lt;/td&gt;';   
  echo '&lt;/tr&gt;';
  
  echo '&lt;tr&gt;';
      echo '&lt;th&gt;Prenume:&lt;/th&gt;&lt;td&gt;&lt;input type="text" name=prenume value="';
       for($value=1;$value&lt;count($nume);$value++) {
                $c=$c."".$nume[$value];          
             }  
      echo $c;
      echo '"&gt;&lt;/td&gt;';
      echo '&lt;td style=color:red&gt;';
      echo $err_prenume;
      echo $err_prenume1;
      echo '&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  
  echo '&lt;tr&gt;';
      echo '&lt;th&gt;CNP:&lt;/th&gt;&lt;td&gt;&lt;input type="text" name=cnp value="';
      echo $cnp;
      echo '"&gt;&lt;/td&gt;';
      echo '&lt;td style=color:red&gt;';
      echo $err_cnp;
      echo $err_cnp1;
      echo $err_cnp2;
      echo '&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  
  echo '&lt;tr&gt;';
      echo '&lt;th&gt;Data angajare:&lt;/th&gt;&lt;td&gt;&lt;input type="text" name=data value="';
      echo $rand['data'];
      echo '"&gt;&lt;/td&gt;';
      echo '&lt;td style=color:red&gt;';
      echo $err_data;
      echo '&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  
  $companii=array("S.C. 2K Telecom S.R.L.", "S.C. Accessnet International S.R.L.", "S.C. Ad Net Market Media S.A.", "S.C. Idilis S.R.L.", "S.C. Infratel Net S.R.L.");
  echo '&lt;tr&gt;';
      echo '&lt;th&gt;Compania:&lt;/th&gt;';
      echo '&lt;td&gt;';
      echo '&lt;select name=companie&gt;';
      //echo '&lt;option value="alege"&gt;Alege compania&lt;/option&gt;';
      //if(!isset($_POST['companie'])){
          echo '&lt;option value='.$companie.'&gt;'.$companie.'&lt;/option&gt;';
          $key=array_search($companie, $companii);
          unset($companii[$key]);
      //}
      foreach($companii as $firme) {
  
  echo '&lt;option value="'.$rand['companie'].'"';
  if(isset($_POST['companie']) &amp;&amp; $_POST['companie'] == $firme) {echo " selected";}
  echo "&gt;$firme&lt;/option&gt;";
         }   
  echo '&lt;/select&gt;';   
  echo '&lt;/td&gt;';   
  echo '&lt;td style=color:red&gt;';
  echo $err_companie;
  echo '&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  echo '&lt;tr&gt;';
  echo '&lt;th&gt;Functia:&lt;/th&gt;&lt;td&gt;&lt;input type="text" name=functie value="';
  echo $rand['functie'];
  echo '"&gt;&lt;/td&gt;';
  echo '&lt;td style=color:red&gt;';
  echo $err_functie;
  echo '&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  echo '&lt;tr&gt;';
  echo '&lt;td  align=center&gt;&lt;a href=tabel.php&gt;&lt;input type=button name=button value=Inapoi!&gt;&lt;/a&gt;&lt;/td&gt;';
  echo '&lt;td  align=center&gt;&lt;input type=submit name=submit value=Introducere! &gt;&lt;/td&gt;';
  echo '&lt;td  align=center&gt;&lt;input type=reset name=reset value=Resetare! &gt;&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  echo '&lt;tr&gt;';
  echo '&lt;td colspan="2" align=center&gt;'.$up.'&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  echo '&lt;/form&gt;';
  echo '&lt;/table&gt;';
  </code></pre>
  
  <p>So this form contains the old values from the table row i've pressed the button,and i want to cahnge with new values.Any idea?</p>