This topic is locked

How to copy fields from master to detail?

11/16/2012 8:18:59 AM
PHPRunner General questions
E
egsiii author

Login info is saved in a Users table
UsersTable:
UserID

FullName

Address

.

.

.
I have an application table that stores info about an application
ApplicationTableA:
ApplicationTableAID

UserID

FullName

Address

.

.

.
On (ADD) ApplicationFormA_add.php my goal is to copy FullName / Address from Users (Master) table to ApplicationFormA (Details) table.
Anyone have example code to copy data from a master table to one of its detail tables?
Thanks;
Ed Schneider

Sergey Kornilov admin 11/16/2012

Sample code:

global $strTableName, $conn;

$str = "select * from users where UserID=".$_SESSION[$strTableName."_masterkey1"];

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$_SESSION["FullName"] = $data["FullName"];


Then use $_SESSION["FullName"] as a default value of FullName field in details table.