This topic is locked
[SOLVED]

 Copy selected records from a list to a new one !

9/11/2012 11:29:31 AM
PHPRunner General questions
N
netmedia59 author

PHPRunner 6.1
Hello,
Is there a way to copy some checked records from a list to another one (a copy) ?

For example with a button
Thanks very much
Olivier

Lille (FRANCE)

Sergey Kornilov admin 9/11/2012

Lilie,
take a look at this article:

http://www.xlinesoft.com/phprunner/docs/update_multiple_records.htm
Instead of issuing UPDATE method build and execute INSERT that will add data to another table.

N
netmedia59 author 9/12/2012

Hey,
Thanks for your answer
I have now this code.

It creates new records but only with the last field (SalonID) wich is calculated
global $dal;

for ($i=0; $i<count($keys); $i++)

{

// set ReportsTo field to 'Bob Smith'

$strSQLInsert = "insert into inscrits (Nom,Prenom,ProEmail,SalonID) values ('$values[Nom]', '".$values["Prenom"]."', '".$values["ProEmail"]."', '$_SESSION[Salon_Num]')";

CustomQuery($strSQLInsert);

}
$result["txt"] = "Records were copied.";
Do you know what I'm doing wrong ?

Thanks for your advices !
Olivier
Lille(FRANCE)

Sergey Kornilov admin 9/12/2012

Lilie,
it's impossible to tell what's wrong with this code without running it against your database. My suggestion is to check this article that explains how to troubleshoot custom buttons:

http://xlinesoft.com/blog/2012/05/16/troubleshooting-custom-buttons-in-phprunner-and-asprunnerpro-applications/
If you have a valid support contract post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

N
netmedia59 author 9/12/2012

Thanks Sergey,
I've done it

Project pri_02
Olivier

Sergey Kornilov admin 9/12/2012

Olivier,
open a ticket at http://support.xlinesoft.com sending your Demo Account URL and explaining what doesn't work so we can troubleshoot your code.

N
netmedia59 author 9/14/2012

Here is the anwer from Jane ... and it works as expected !

Thanks again
Here is just a sample 'Server' code:

-----------------

global $dal;

for ($i=0; $i<count($keys); $i++)

{

// copy records from table1 to table2

$sql = "insert into table2 (fieldname1, fieldname2, fieldname3) select fieldname1, fieldname2, fieldname3 from table1 where KeyField="

. $keys[$i]["KeyField"];

CustomQuery($sql);

}
$result["txt"] = "Records were copied.";