This topic is locked

insert record into another table

9/17/2007 4:12:50 PM
PHPRunner General questions
L
luck author

Hi,
I have 2 table.
_candidats
Username

Password

FirstName

LastName

ID
_login

Username

Password

ID
I want to insert data from first table from fields Username and Password directly in second table in Username and Password fields. Can anyone tell me how to do that?
Thanks!

L
luck author 9/18/2007

Hi,
I am a newbie, and maybe i was not to clear about want i need.
When i add information on the first table _candidats, i want to automatic appear(insert) the data coresponding to Username and Password in second table _login.
Thanks!

Sergey Kornilov admin 9/19/2007

It's not clear when you need to insert it.
What event do you use?

L
luck author 9/19/2007

It's not clear when you need to insert it.

What event do you use?


Hi,
I use event before record added - insert a record into another table.
But i do not know how to change this event to do what i need to do.
I tried this code but i do not know what to put in values and i'm not sure if this is what i must do to resolve my problem.
global $conn;

$strSQLInsert = "insert into _login (Username, Password) values (Value1, Value2)";

db_exec($strSQLInsert,$conn);
And i need another solution to change a value for a field. On event: after record added i want to change value of one field to NULL. I added a field in login table: Activate profile, and i want after record in added in the first table to change or delete the record from Activate profile field.
Thank you for your support!

J
Jane 9/19/2007

Hi,
all entered values on the add page is stored in the $values array.

Try to use this code:

global $conn;

$strSQLInsert = "insert into _login (Username, Password) values ('".$values["UserName"]."','".$values["Password"]."')";

db_exec($strSQLInsert,$conn);


To change field value in the _candidats table use this code:

$values["ActivateProfile"]=NULL;



where ActivateProfile is your actual field name.

Please note field names are case sensitive here.

L
luck author 9/19/2007

Hi,

all entered values on the add page is stored in the $values array.

Try to use this code:
To change field value in the _candidats table use this code:
where ActivateProfile is your actual field name.

Please note field names are case sensitive here.


Thank you very much! You put a smile on my face!