title: Update MySQL using an array
body: <p>Is it possible in PHP using MySQLi to update a table with an array without knowing the field names, how many there is and their values.</p>
  
  <p>I've tried with prepared statements inserting a question mark on key and value field (?=?). I was thinking if it's possible to use () VALUES () in a update query I might have a solution but no such thing exists I guess.</p>
  
  <p>Look at my script:</p>
  
  <pre><code>&lt;?php
      class UserHandler {
          public function updateUserData($array, $id) {
              global $mysqli;
              $stmt = $mysqli-&gt;prepare("UPDATE users SET ?=? WHERE id = ?");
              $stmt-&gt;bind_param('ssi', $array[0], $array[1], $id);
              $stmt-&gt;execute();
              return true;
          }
      }
  
      $users = new UserHandler;
  ?&gt;
  </code></pre>
  
  <p>I want the usage to be like this:</p>
  
  <pre><code>&lt;?php
      $users-&gt;updateUserData(array(
          'firstname' =&gt; 'Wanda',
          'lastname' =&gt; 'Merritt',
          'state' =&gt; 'IN'
          'address' =&gt; '693 Pearcy Avenue',
          'zipcode' =&gt; 46625,
      ), 45);
  
      $users-&gt;updateUserData(array(
          'firstname' =&gt; 'Stanley',
          'lastname' =&gt; 'Lewis',
          'password' =&gt; '123123'
      ), 159);
  ?&gt;
  </code></pre>