title: Update multiple columns with multiple values in one single table
body: <p>I'm making a very simple stock control system. In the page that the user will be able to do the updates, I'm listing all the contents in the table and putting everything in text fields, like the image.<img src="https://i.stack.imgur.com/SxBUN.png" alt="Stock control example"></p>
  
  <p>So, the user should just change what he wants and when he clicks on submit, it would update every row in the table, with its respective value. But my code isn't working. I don't know how to make this kind of update and I'm sure it's wrong, because it doesn't even work. Here my form:</p>
  
  <pre><code>&lt;form action="update_pcs.php" method="POST"&gt;
              &lt;label&gt;Peça&lt;/label&gt;
              &lt;label for="txtQtd" id="qtd"&gt;Qtd.&lt;/label&gt;
              &lt;br/&gt;
                  &lt;?php foreach($rtn as $pcs){ ?&gt;
                          &lt;input type="text" name="txtNome[]" id="txtNome" value="&lt;?=$pcs['pc_nome']?&gt;" /&gt;
                          &lt;input type="text" name="txtQtd[]" id="txtQtd" value="&lt;?=$pcs['num']?&gt;"/&gt;
                          &lt;input type="hidden" name="txtId[]" id="txtId" value="&lt;?=$pcs['id']?&gt;" /&gt;
                          &lt;br /&gt;
                          &lt;br /&gt;
                  &lt;?php } ?&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;input type="submit" value="Enviar" name="btnEnvia" /&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>And my file <code>update_pcs.php</code>, which should do the update in the table.</p>
  
  <pre><code>&lt;?php
  
      include_once 'mdl.php';
      $conexao = new modelDB();
  
      $qtd = $_POST['txtQtd'];
      $nom = $_POST['txtNome'];
      $id = $_POST['txtId'];
  
      /*This makes the $dados array keep in the value ['nome'] another array, the value ['qtd'] another array and ['id'] another array*/
      $dados = array('nome'=&gt;$nom,
                      'qtd'=&gt;$qtd,
                      'id'=&gt;$id);
  
  
      foreach($dados as $dado){
  
          /* I'm doing it that way but it isn't working */
          $nomeAt = $dado['nome'];
          $qtdAt = $dado['qtd'];
          $id = $dado['id'];  
  
          $conexao-&gt;alteraDb("update pcs_estq set pc_nome ='{$nomeAt}', num = '{$qtdAt}' where id = '{$idAt}'");
      }
  </code></pre>
  
  <p>My function must be right because when I change the php variables for values, it works. How could I make this right?</p>