This topic is locked

How To Copy data from a table to outher Table?

3/18/2008 11:40:33 AM
PHPRunner General questions
S
sickacid author

Hi Support,

In the After Record added,i need to copy some fields data , from a table to outher table but i can copy only values like number

not text, and i can't copy che result of dropdown menu. What can i do?

Alexey admin 3/19/2008

Simone,
the values entered by the user on the Add page can be accessed thru $values array in the After record added event.

So use them to build INSERT SQL string and execute it.

Here is the sample code:

global $conn;

$sql = "insert into Table2 (Field1,Field2) values ('".db_addslashes($values["Field1"])."','".db_addslashes($values["Field2"])."')";

db_exec($sql,$conn);

S
sickacid author 3/19/2008

Simone,

the values entered by the user on the Add page can be accessed thru $values array in the After record added event.

So use them to build INSERT SQL string and execute it.

Here is the sample code:


This works very well.. i've got another question, i want to filter this operation with an if

but this don't work..
global $conn;

if(.db_addslashes($values["Descrizione"]).)=='MULTA' Then $strSQLInsert = ....

...

where is my error?

Thank you!

Alexey admin 3/19/2008

Simone,
I suppose here is the code you need:

if($values["Descrizione"]=='MULTA') ...


Here are some links where you can learn PHP syntax:

http://www.php.net/docs.php

http://www.webcheatsheet.com/php

http://www.w3schools.com/php/