Here there is one table having field id, name,value. There is one form with field meta title, meta description, when I insert values are insert like
id name value
1 meta title testtitle(this is value of textbox of meta title in form)
1 meta description testdes
insert and delete function is working correctly but edit/update function is not working properly. here my update function :
function mysql_updatemetapost($db, $columns) {
$sql = "";
foreach ($columns as $obj) {
$sql = "UPDATE user_metapost SET value = '{$obj['value']}' WHERE
user_postid='" . $obj['user_postid'] . "' AND name= '" . $obj['name'] . "'";
$result = mysql_query($sql, $db) or die(mysql_error());
}
return $result;
}
Columns is an array contain data of form. here when updating records the name field value(meta title,meta description) should not be change, here in this code the problem is that when I update it will insert last value of columns array, it means meta description is updated, example :
after update table data are :
id name value
1 meta description updateddes(this is value of textbox of meta title in form)
1 meta description updateddes