Return to Snippet

Revision: 22885
at January 25, 2010 11:25 by ginoplusio

Initial Code
function duplicateRow($table,$primaryField,$primaryIDvalue) {
	// duplicate one record in a table
	// and return the id
	$fields = getCommaFields($table,$primaryField);
	$sql = "insert into $table ($fields) select $fields from $table where $primaryField='".mysql_real_escape($primaryIDvalue)."' limit 0,1";
	mysql_query($sql) or die(mysql_error().$sql);
	return mysql_insert_id();

Initial URL

Initial Description

Initial Title
Duplicate one row in a MYSQL table through PHP

Initial Tags

Initial Language