try this one. just pass for $_value an array with your table fieldname as your key function constructUpdate( $_tbl_name, $_where, $_values ) { $valstr = ''; $firstval = false; if (is_array($_values)) { foreach( $_values as $key=>$val ) { if ($val != '') { if( $firstval ) $valstr.= ','; if (is_string($val)) { $valstr.= " $key = '$val'"; } else { $valstr.= " $key = $val"; } $firstval = true; } } } else { $valstr = $_values; } $retStr = "update $_tbl_name set $valstr"; if( $_where ) $retStr.= " where $_where"; return $retStr; }