This topic is locked

using master field in detail table

2/28/2009 6:28:07 PM
PHPRunner General questions
D
danaci author

hello,

I have two table(master and detail)
master and detail table relating for sno fields.
master table
sno int(6),

name varchar(30),

code varchar(10)
detail table
sno int(6),

g_tarih date,

aciklama varchar(10)
insert new record or edit record events

how do can I using master table code value in detail table aciklama?

or

detail table aciklama= master table code?


thnx.

J
Jane 3/2/2009

Hi,
select value from master table in the Add page: Before process event and save it in the session variable:

global $conn, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$str = "select code from MasterTable where sno=".$_SESSION[$strTableName."_masterkey1"];

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

$data = db_fetch_array($rs);

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

}


Then use $_SESSION["code"] as default value on the "Edit as" settings dialog on the Visual Editor tab.