Jump to content

How do I create a "Duplicate Record" button that populates a new increment


rushingfs

Recommended Posts

I am a noobie that wants to modify a script that has a form with a "delete" and "edit" button.  I would like to add a "duplicate" button that will automatically populate the fields with data from user's last record while assigning it a new increment.

Thank you!
Suppose the table has column names id, a, b, c.

$sql = "INSERT INTO tablename (a, b, c) SELECT a, b, c FROM tablename WHERE id = '$selectedID' ";

In other words select all cols form original record [b]except[/b] the id and insert them into the table as a new record. Note it won't work if you have unique key constraints on a, b or c.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.