title: PHP PDO Update multiple rows
body: <pre><code>foreach($results as $row){
  echo "
   &lt;input type='text' name='p_name' placeholder='" . $row['p_name'] . "'&gt;
   &lt;input type='text' name='p_description' placeholder='" . $row['p_description'] . "'&gt;
   &lt;input type='text' name='p_price' placeholder='" . $row['p_price'] . "'&gt;
   &lt;input type='hidden' name='product_id'&gt;
   &lt;input type='submit' name='update' value='update'&gt;
   ";
  }
  echo "&lt;/form&gt;";
  
  if(isset($_POST['update'])){
  
  $values = [
    'product_id' =&gt; $_POST['product_id'],
   'p_name' =&gt; $_POST['p_name'],
  ];
  
  $stmt = $pdo-&gt;prepare('UPDATE products SET p_name = :p_name WHERE 
  product_id = :product_id'
  );
  unset($_POST['update']);
  
  
  foreach($values as $row){
   $stmt-&gt;execute($row);
  }
  
  }
  </code></pre>
  
  <p>I'm trying to update multiple fields inside a database so when I update the product name for one of them, I want it to then be sent to the database. However it won't submit that specific row with the ID and instead skips to the the last one and insert blank data. How am I able to pick which specific product name i want to update? So basically updating the data inside a database with many rows.</p>