title: how to update an array from input box in php mysql
body: <p>This is my code:</p>
  
  <pre><code>$uid=$_POST['uid'];
  $fields = '';
  if($uid==1){    
  //having some error in this line
     foreach($query as $key =&gt; $value) {
      if ($i++ != 0) $fields .= ', '; 
      $key = mysql_real_escape_string($key);
        $value = mysql_real_escape_string($value);
        $fields .= "$key = $value";
        }
  $query = mysql_query("UPDATE 2mcom SET $fields");
     }
  
  
  
    echo "&lt;table&gt;" ;
  $result = mysql_query("select * from 2mcom where roll_no='138218600004'");
  $i=1;
  
  while (false != ($data = mysql_fetch_array($result, MYSQL_ASSOC)))
    foreach ($data as $key =&gt; $value)
    //echo "$key: $value &lt;br /&gt;";
    {
    echo "&lt;tr&gt;&lt;td&gt;";
      echo "$key: ";
    echo "&lt;/td&gt;";
      echo '&lt;form method="post" action=""&gt;';
      echo "&lt;td&gt;";
      echo '&lt;input type="text" name="fld'.$i.'" value="'.$value.'"/&gt;';
      echo '&lt;input type="hidden" name="uid" value="1"/&gt;';
       $i++;
       echo "&lt;/td&gt;&lt;/tr&gt;";
    }
    echo "&lt;tr&gt;&lt;td&gt;";
     echo'&lt;input type="submit" name="submit" value="submit"/&gt;';
  
    echo "&lt;/tr&gt;&lt;/td&gt;";
      echo'&lt;/form&gt;&lt;/table&gt;';
  </code></pre>
  
  <p>I want to update this table 2mcom from the input text-box. Here i am fetching the field-name along with their values in input field from table "2mcom" using array.. now i want to update the field after editing.it is for result correction .</p>