update using array
/* function to build SQL UPDATE string */
function build_sql_update($table, $data, $where)
{
$cols = array();
foreach($data as $key=>$val) {
$cols[] = "$key = '$val'";
}
$sql = "UPDATE $table SET " . implode(', ', $cols) . " WHERE $where";
return($sql);
}