rushingfs Posted January 10, 2007 Share Posted January 10, 2007 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! Link to comment https://forums.phpfreaks.com/topic/33634-how-do-i-create-a-duplicate-record-button-that-populates-a-new-increment/ Share on other sites More sharing options...
Barand Posted January 10, 2007 Share Posted January 10, 2007 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. Link to comment https://forums.phpfreaks.com/topic/33634-how-do-i-create-a-duplicate-record-button-that-populates-a-new-increment/#findComment-157633 Share on other sites More sharing options...
rushingfs Posted January 10, 2007 Author Share Posted January 10, 2007 Thank you for the quick reply. I'll try that. Link to comment https://forums.phpfreaks.com/topic/33634-how-do-i-create-a-duplicate-record-button-that-populates-a-new-increment/#findComment-157648 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.