This is my code:
$uid=$_POST['uid'];
$fields = '';
if($uid==1){
//having some error in this line
foreach($query as $key => $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 "<table>" ;
$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 => $value)
//echo "$key: $value <br />";
{
echo "<tr><td>";
echo "$key: ";
echo "</td>";
echo '<form method="post" action="">';
echo "<td>";
echo '<input type="text" name="fld'.$i.'" value="'.$value.'"/>';
echo '<input type="hidden" name="uid" value="1"/>';
$i++;
echo "</td></tr>";
}
echo "<tr><td>";
echo'<input type="submit" name="submit" value="submit"/>';
echo "</tr></td>";
echo'</form></table>';
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 .