title: PHP -> PDO Update Function using Foreach array merge
body: <p>The following code is supposed to check for the column names of a table. Then check to see if a corresponding variable has been $_POST and if it has add it to the $SQL. I believe there is a problem with the array that contains a series of arrays but I don't know how to dix it.</p>
  
  <pre><code>$where = $_POST['where'];
      $is = $_POST['is'];
      $table = $_POST['table'];
      $sql = "UPDATE $table SET";
      $array = array();
  
      $columnnames = columnnames('blog');
      foreach ($columnnames as $columnname){
  
          if($_POST[$columnname]){
              $sql .= " $columnname = :$columnname,";
              $array .= array(':$columnname' =&gt; $_POST[$columnname],);
          }
  
      }
      $sql = rtrim($sql,',');
      $array = rtrim($array,',');
  
      $sql .= " WHERE $where = '$is'";
      $q = $rikdb-&gt;prepare($sql);
      $q-&gt;execute($array);
  </code></pre>
  
  <p>For the sake of comprehension please except that <code>$columnnames = columnnames('blog');</code> works as it does.</p>