This topic is locked

Show Data From Another Table Using Before Processing Event

5/2/2013 4:26:44 AM
PHPRunner General questions
A
apatani author

I have three tables with a "cascading" master-detail relationship as follows:

Table1: [Table1_id, Table1_data, .....]

Table2: [Table2_id, Table1_id, Table2_data, ...} , where Table1_id in the two tables link Table1 and Table2

Table3: [Table3_id, Table2_id, Table3_data, ....], where Table2_id in the two tables link Table2 and Table3
On the Add Page of Table 3 generated under a given record in Table2 List Page, I would like to show/"echo" Table1_data (corresponding to Table1_id in Table2) so that the user can visually see that the data is being put under the correct Master form.
I have tried using DAL, but find that using Before Processing event or Before Add event I am not able to display the value (i.e. it shows up as NULL). Here is the code I tried:
global $dal, $conn;

$sql = "select Table1.Table1_data as Table1_data from Table1

inner join Table2 on Table1.Table1_id = Table2.Table1_id

inner join inv_adj on inv_adj.Table2_id = Table2.Table2_id

where inv_adj.Table2_id = '".$values["Table2.Table2_id"]."'";

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);

echo "Product: " .$data["Table1_data"];
Adding echo "Table2_id: " .$values["Table2_id"]; before the $sql statement, I do not see any message being echoed. I therefore surmise that I am not able to capture the value of Table2_id.
Is this to be expected? How should I modify my code to display the value?
Thanks.