title: MySQLi query to loop through array and update multiple rows
body: <p>I have an array like:</p>
  
  <pre><code>$postdata[1] = 'This';
  $postdata[2] = 'That';
  $postdata[3] = 'The other';
  </code></pre>
  
  <p>And I want to loop through the array and update all of the rows where <code>ID</code> corresponds to the array key. Like: </p>
  
  <pre><code>foreach ($postdata as $key =&gt; $value) {
    if ($key == 1) {
      $update = $db-&gt;query("UPDATE site_email_templates SET Content='$postdata[1]' WHERE ID = 1");
    } else if ($key == 2) {
      $update = $db-&gt;query("UPDATE site_email_templates SET Content='$postdata[2]' WHERE ID = 2");
    } else if ($key == 3) {
      $update = $db-&gt;query("UPDATE site_email_templates SET Content='$postdata[3]' WHERE ID = 3");
    }
  }
  </code></pre>
  
  <p>What would be the simplest way to do this, not particularly knowing how many array keys there are, and keeping it all in one query?</p>