This topic is locked

master table info displayed on ADD page

8/22/2005 10:50:14 AM
PHPRunner General questions
C
crono999 author

Regarding previous postings of mine, I have found out how to direct a user directly from the LIST page of a master table to it's child's ADD page when they click the child's table name. However, I'm wondering if I can have the master table data displayed across the top of the ADD page like it is on the child's LIST page. Thank you for any help possible...

admin 8/23/2005

Hi,
here is what you should do to display master table info on Add page.

  1. Copy DisplayMasterTableInfo, GetLinkPrefixMaster and AddLinkPrefixMaster functions from the end of ..._list.php to ..._add.php
  2. Insert the following lines

$masterkey=$_SESSION[$strTableName."_masterkey"];

$detailkeyfield=RemoveFieldWrappers("`ORDERID`");

just before

$defvalues=array();

line in ...add.php. "$detailkeyfield=.." line shoul be copied from ..._list.php
3. Find the snippet looking like this in ..._list.php and insert it in ...add.php after two lines inserted before. Don't forget to take care of <?php ?> elements.

<?php if($masterkey) {?>

<table><tr><td width=20>&nbsp;</td><td><p>Master table: [orders]</p></td></tr></table>

<table rows='1' cols='1' align='center' width='95%' border='0'>

<tr><td align="right">

<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>

<TR><TD BGCOLOR=black align=center>

 <table border=0 width=100% CELLPADDING=3 CELLSPACING=1>

 
<?php

$strMasterSQL = AddWhere("select `ID`,   `TIME`,   `Customer`   From `orders` ",AddFieldWrappers("`ID`")."=".make_db_value($detailkeyfield,$masterkey));

LogInfo($strMasterSQL);

$rsMaster=db_query($strMasterSQL,$conn);

DisplayMasterTableInfo($rsMaster);

?>

</table>

</td></tr></table>

</td></tr></table>
<?php } ?>
C
crono999 author 8/26/2005

worked beautifully, thank you.

did have some issues with the <?php ?> elements just as you warned about though.