This topic is locked

AdOnLoad or Before Display event

9/11/2008 9:27:40 AM
PHPRunner General questions
V
vytb author

Hello,
I'm having numerous childrecords 'visit' for the same master.
I would like to autofill a field for the next (subsequent) child record field from the previous child.
Let's say a value for the same field A, where 'SubjectId' is foreign key and 'id' is primary autoincremental key from the identical field 'A' from the similar record having the same 'SubjectId' and different 'id'.
However I would like to see these values on load. What event to use, AdOnLoad or Before Display, and what to change in code correspondingly?
In beforeAdd event, I would be something like
[codebox]global $conn,$where,$strTableName;

$str = "select visit.A from visit where SubjectId=".$_SESSION[$strTableName."_masterkey1"];

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

$data = db_fetch_array($rs);
$values['A']=$data['A'];

return true;

[/codebox]

J
Jane 9/12/2008

Hi,
you need to use Before display event.

Here is a sample code:

global $conn, $strTableName;

$str = "select visit.A from visit where SubjectId=".$_SESSION[$strTableName."_masterkey1"];

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

$data = db_fetch_array($rs);
$smarty->assign("value_A",$data["A"]);