Julian Posted October 31, 2006 Share Posted October 31, 2006 Hi guysWhat I want to do is this:I have a form which insert the info into the database. Then I have a result page where I can see the info on the database. I put a edit button and delete button in order to admin the database. That works great. Here's the thing: I want to add a duplicate button after the edit and delete, so, the user can duplicate the info on the database entry and edit only the part he needs and keep the original. It's like a "save as" option.Any help help will be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/25755-how-to-duplicate-a-database-entry/ Share on other sites More sharing options...
the_oliver Posted October 31, 2006 Share Posted October 31, 2006 Hi,I would do this by adding an aditional coloum into your database table, for the pourpous of identifying each entrie, and seting this to automaticaly incrament every time a new row is added. (what database type are you using?) This garanties you a unique id number for each entrie. you can then add a new row into the database containing the data you have already have pulled out, the only diffrence being the id it is assgned. Your can then get this new ID number by serching for SELECT id_coloums_name FROM table_name WHERE coloum_of_origional_data ILIKE 'data_on_page' (example is pgSQL but simialar format for most). This will of course give you more then one option, but you can ignor the one of the origional data. (store this in a variable when you make your first poll for the origional data). Then the changes the made can be updated using this ID number as a refrance point in the table. . . .In a less long winded way:1) re-insert the data, using auto_incriment id.2) get new id number3) Update changes using the new id number The only problem with this is that if you have a large table adding to it will make poll's slowly slower. Can get round this by having a second table to store the altered dater/'save as' versions in.Hope i havent discribed this to much like mud! There may well be better ways. Quote Link to comment https://forums.phpfreaks.com/topic/25755-how-to-duplicate-a-database-entry/#findComment-117593 Share on other sites More sharing options...
Julian Posted November 1, 2006 Author Share Posted November 1, 2006 Thanks.I'm working on PHP and MySQL Table. You're right I just want to insert a duplicate row with a new id (id is primary key and has autoincrement attribute).Can you tell me how to put this on a MySQL query or PHP code? Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/25755-how-to-duplicate-a-database-entry/#findComment-117869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.