CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Duplicate Record

Print topic Send  topic

Author Message
FERAD
Posted: 09/28/2004, 4:24 PM

Is there a simple way to copy one record from a Mysql table to a new record in the same table?

Can this be done by adding a "copy button" on the Edit Record Form page? Is there a better way?

The records have a unique ID field that is set to automatically increments with each new record. All the rest of the fields can remain the same.

Any help would be greatly appreciated.
johny_f

Posts: 23
Posted: 09/28/2004, 10:47 PM

I have two ways
----------------------
1. In "ADD NEW" mode I pull data from required record to the fields as "default" values. In that way user can easily adjust data into his way...
Everything is done with custom coding in before show event
You can use Dlookup function if there is only one or few culoms, for more items is better to use standard mysql/php coding:

$db = new clsDBconnectionname();

$SQL = "Select..." ;
$db->query($SQL);

$xcount = $db->num_rows(); //numrows

$Resultc_id = $db->next_record(); // get record

if ($Resultc_id)
{
$item1 = $db->f("conf_reg_id"); // get certain field from DB

// set value to the form component
$formname->textboxname->SetValue($item1);
}


unset($db);

you can easily add button that will link to page with above function or will activate sucha function.

2. Is pure mysql
Pulling data from DB
- SELECT * ... from Where record_id = XXX
...
$item1 = $row[culom_name1]
$item1 = $row[culom_name2]
...

and finally INSERT...

== This is just a scheme not coding ==


I dont know your level of mysq knowledge, hopefuly you undrestand.

_________________
Johny_f
View profile  Send private message
klwillis


Posts: 428
Posted: 09/29/2004, 2:09 PM

Assuming you have a table called 'people' with an auto-increment
key field called 'id' ... you could duplicate record 10 (the key id of the record you want to copy) with this SQL:

insert into people (select * from people where id = 10); 8-)

_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"

Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.