php操作MYSQL数据库无法更新问题解决

function update($table_name, $field, $subquery){
$query = '';
foreach ($field as $index => $value){ 
$value = addslashes($value);
if (!$query) {$query = "`$index` = '$value'"; }else{$query .= ", `$index` = '$value'";}}
$query = "UPDATE `$table_name` SET " . $query . ' ' . $subquery;
$link = mysql_query($query);
return $link;}

用这个函数是下
$arr['idata']=$_post['aa']
update(data1);

你可能感兴趣的:(mysql,PHP,数据库,table,query,subquery)