This topic is locked

Links on list pages of details pages

1/12/2009 10:18:54 AM
PHPRunner General questions
M
mmponline author

I have a main table with master / detail relationships links setup on it to 5 details tables. It works fine and when you click on the links it goes to the list page of the detail page.
I now have a need to add links on each of the details pages to go to the corresponding details table for that specific master record. In other words, the same link as on the list page of the master table to each of the different details table's list pages. Just copying the code does not work.
Further, I like to use a picture instead of a link.
Please help!

J
Jane 1/13/2009

Hi,
to add links to another detail table use custom event (Insert PHP code snippet option on the Visual Editor tab).

Here is just a sample:

global $strTableName;

if (@$_SESSION[$strTableName."_masterkey1"] && @$_SESSION[$strTableName."_mastertable"])

echo "<a href=\"AnotherTableName_list.php?mastertable=".$_SESSION[$strTableName."_mastertable"]."&masterkey1=".$_SESSION[$strTableName."_masterkey1"]."\"><IMG src=\"images/imagename.jpg\"></a>";

M
mmponline author 1/13/2009

This works just fine. Thanks a lot!
I also need to alter / adjust this code to NOT show the link when the related table's field has nothing in it. IOW it must only show a link when that field contains info.
Please assist.

J
Jane 1/14/2009

Stephan,
here is a sample:

global $strTableName,$conn;

if (@$_SESSION[$strTableName."_masterkey1"] && @$_SESSION[$strTableName."_mastertable"])

{

$str = "select * from AnotherTableName where DetailKey=".$_SESSION[$strTableName."_masterkey1"];

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

if ($data = db_fetch_array($rs))

echo "<a href=\"AnotherTableName_list.php?mastertable=".$_SESSION[$strTableName."_mastertable"]."&masterkey1=".$_SESSION[$strTableName."_masterkey1"]."\"><IMG src=\"images/imagename.jpg\"></a>";

}

M
mmponline author 1/17/2009

Works 100%. Thanks a 1 000 000!