This topic is locked

Copy Field from one table to another table

10/7/2007 9:44:03 PM
PHPRunner General questions
B
bricris author

I'm using PhpRunner 4.1 build 320.
I have two tables.
[codebox]1. Table1
select `ID`,

`payment_ID`,

`First Name`,

`Last Name`,

`UserName`,

`Passcode`,

`Email Address`,

`Address1`,

`Address2`,

`City`,

`State`,

`Zip`,

`Home Phone`,

`Work Phone`,

`Mobile Phone`,

`Terms & Conditions`,

`Emergency Contact Name`,

`Emergency Home Phone`,

`Emergency Work Phone`,

`Emergency Cell Phone`,

`Student Name`,

`Gender`,

`Shoe Size / Fin Size`,

`Neighborhood Sub-Division`,

`School Name`,

`Track / Traditional / Home School`,

`Student's Age`,

`Student Name 2`,

`Student's Age 2`,

`Gender 2`,

`Shoe Size / Fin Size 2`,

`School Name 2`,

`Track / Traditional / Home School 2`,

`Student Name 3`,

`Student's Age 3`,

`Gender 3`,

`Shoe Size / Fin Size 3`,

`School Name 3`,

`Track / Traditional / Home School 3`,

`current_family`,

`ID2`,

`Notes`,

`Dataandtime`

From `_Table1`[/codebox]

[codebox]

2. Payments
select `ID`,

`First Name`,

`Last Name`,

`UserName`,

`payment_ID`,

`Paid`,

`Amount`,

`Check Number`,

`Notes`,

`Class Description`,

`Group Name`,

`Time`,

`Session`

From `_Payment` [/codebox]
I"m using Master Detail with the key of UserName.
All I want to do is when a new payment record is created is copy the "First Name" and "Last Name" from "Table1" to the fields in Payment "First Name" "Last Name"
I have been looking and looking on how to do this but I need help.
Brian

J
Jane 10/8/2007

Brian,
you can do it using Before record added event on the Events tab for the Table1.

Here is a sample code:

$_SESSION["First Name"]= $values["First Name"];

$_SESSION["Last Name"] = $values["Last Name"];



And then use $_SESSION["First Name"] and $_SESSION["Last Name"] as default values for the Last Name and First Name fields on the "Edit as" settings dialog on the Visual Editor tab.

B
bricris author 10/8/2007

Brian,

you can do it using Before record added event on the Events tab for the Table1.

Here is a sample code:
And then use $_SESSION["First Name"] and $_SESSION["Last Name"] as default values for the Last Name and First Name fields on the "Edit as" settings dialog on the Visual Editor tab.


Thanks this works great but I have to Edit the Table1 Record and then go to the Payment Record so that the names will show up in the fields.
I just can't add a payment record and have the names show up in the field.
Brian

J
Jane 10/9/2007

Brian,
to do the same on the edit page add the same code to the Before record updated event for the Table1 on the Events tab.
Then add the following code to the Edit page: Before Display event for the Payments table:

$smarty->assign("value_Last_Name") = $_SESSION["Last Name"];

$smarty->assign("value_First_Name") = $_SESSION["First Name"];

B
bricris author 10/13/2007

Ok this is not working for me I have put everything in but I get a error.
All I want to do is when I click on Payment or (Add New Payment) I want the First Name and Last Name to copy from Table1 to Payment.
I don't know what I'm doing wrong but It is not working.
If you can help that would be great.
I want to do that so I can search payments to find out who has paid.
Thank You
BriCris

Brian,

to do the same on the edit page add the same code to the Before record updated event for the Table1 on the Events tab.
Then add the following code to the Edit page: Before Display event for the Payments table:

Alexey admin 10/15/2007

Brian,
contact support team directly.

Post your app to Demo Account (last tab in PHPRunner) and send a link to it with a problem description to support@xlinesoft.com