Description: Iterate over an array and update a mySQL table.
Comment: (none)
Language: PHP, MYSQL Highlight Mode: PHP Last Modified: March 01st, 2009
<?PHP// Parameters:// Table: Name of table to update// Data: array of $field->$value with new values// Id Field: Name of field to use as ID field// Id Value: Value of ID fieldFUNCTION mysql_update_array($table,$data,$id_field,$id_value){FOREACH($dataAS$field=>$value){$fields[]=SPRINTF("`%s` = '%s'",$field,MYSQL_REAL_ESCAPE_STRING($value));}$field_list=JOIN(',',$fields);$query=SPRINTF("UPDATE `%s` SET %s WHERE `%s` = %s",$table,$field_list,$id_field,INTVAL($id_value));RETURN$query;}?>
SQL University.net courses meet the most demanding needs of the business world for advanced education
in a cost-effective manner. SQL University.net courses are available immediately for IT professionals
and can be taken without disruption of your workplace schedule or processes.
Compared to traditional travel-based training, SQL University.net saves time and valuable corporate
resources, allowing companies to do more with less. That's our mission, and that's what we deliver.