close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to duplicate a record in MySQL using PHP

Thread began 6/22/2015 1:49 pm by Daniel | Last modified 6/29/2015 4:08 pm by Ray Borduin | 527 views | 14 replies |

Daniel

How to duplicate a record in MySQL using PHP

The data assist pages have been working great and I can do just about everything I need in my database... except for one thing... I need to duplicate a record, then edit it with new information before committing it to the database. I can do this in phpmyadmin with no problem, but I'd like to be able to do it from my webpage while I'm on a particular record.

Often times I need to enter a new record where 90% of the information is the same but I just need to change a couple of fields.

Do you have any suggestions how I can accomplish this?

Dan Lewis

Sign in to reply to this post

Ray BorduinWebAssist

I think you would probably need to do a custom SQL statement to insert the repeated row and then save the inserted id. Then you can use the webassist update server behavior specifying the inserted id for the custom fields. If you have a sample page and example I could be more specific with the necessary code.

Sign in to reply to this post

Daniel

Duplicate a record

The page I'm using to insert and update records is basically what I created using dataassist. I was thinking maybe the update form would be the best choice since it already has everything in it that I want to copy. I'll give you all the pages however because I've been wrong in the past!

The index.php is actually the search page.

Attached Files
allshows2_detail.php
allshows2_insert.php
allshows2_results.php
allshows2_update.php
index.php
Sign in to reply to this post

Ray BorduinWebAssist

Actually that is a good idea... Copy your update page and name it. allshows2_duplicate.php

Then remove the Update Record server behavior and add an Insert record server behavior. Then you can add a duplicate link to your results page that links to this page passing the ID you want to duplicate.

Sign in to reply to this post

Daniel

Adding Duplicate Button

It worked!!! One additional thing I had to do was to copy the "Insert Button" and actions from the insert page. I've included a copy of the finished product. It works like a charm and a simple solution for anyone else looking to duplicate records! I also put a button on my details page linking to the duplicate page so I can duplicate at that point too.

Once thing I'd like to change on the results form is the Icon that represents the duplication. I made one using photoshop, I just took the details button and made a double spyglass. It looks good but I can't figure out how to get it to appear on the results page.

Attached Files
allshows2_duplicate.php
allshows2_results-with duplicate.php
Sign in to reply to this post

Ray BorduinWebAssist

It looks like we are setting the background-image for the button with .css. Just find the .UpdateButton class in your form css and create a copy for DuplicateButton and then change the class on that button in the HTML.

Sign in to reply to this post

Daniel

Changing the look of a button

I've looked around to try to fine the proper place to duplicate and change the .css but I just can't find how to do it. Could you be a little more specific on the instructions on how to change the .css for the duplicate button.

Sign in to reply to this post

Ray BorduinWebAssist

Do you have a live URL? I could take a look that way.

Sign in to reply to this post

Daniel

Changing the look of a button

I've put a message in the private message section

Sign in to reply to this post

Ray BorduinWebAssist

What is the web site url?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...