This topic is locked
[SOLVED]

 Trying to substitute an ID for a company name - how?

2/2/2011 10:37:33 PM
PHPRunner General questions
K
karmacomposer author

I am using the code for MASTER/DETAIL relationships. I want to people to view the COMPANY NAME (CompName) instead of the key (EmployerID). Here is the code I attempted to modify:
global $dal, $strTableName;

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

{

$tblMaster = $dal->Table("Employer");

$rs = $tblMaster->Query("EmployerID=".$_SESSION[$strTableName."_masterkey1"],"");

if ($data = db_fetch_array($rs))

{

echo "Company Name: ".$data["CompName"];

}

}
I am placing this in the custom VIEW AS section of the field. It still shows the EmployerID (which is what is written to that field). The Company Name is held in a totally different table called Employers. The table people are viewing is called AdminCCHold.
The EmployerID is written to the field HoldBy (in the AdminCCHold table) when someone puts a record on HOLD. This corresponds to the EmployerID of the person putting the record on hold. The actual EmployerID is located in the Employer table.
How do I show the CompName instead of the ID (keep in mind, I have to access another table - the Employer table - from the AdminCCHold table)?
Mike

T
trek46 2/8/2011

Couldn't you set this up as a list and use the employer table as the lookup field?



I am using the code for MASTER/DETAIL relationships. I want to people to view the COMPANY NAME (CompName) instead of the key (EmployerID). Here is the code I attempted to modify:
global $dal, $strTableName;

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

{

$tblMaster = $dal->Table("Employer");

$rs = $tblMaster->Query("EmployerID=".$_SESSION[$strTableName."_masterkey1"],"");

if ($data = db_fetch_array($rs))

{

echo "Company Name: ".$data["CompName"];

}

}
I am placing this in the custom VIEW AS section of the field. It still shows the EmployerID (which is what is written to that field). The Company Name is held in a totally different table called Employers. The table people are viewing is called AdminCCHold.
The EmployerID is written to the field HoldBy (in the AdminCCHold table) when someone puts a record on HOLD. This corresponds to the EmployerID of the person putting the record on hold. The actual EmployerID is located in the Employer table.
How do I show the CompName instead of the ID (keep in mind, I have to access another table - the Employer table - from the AdminCCHold table)?
Mike

K
karmacomposer author 2/8/2011



Couldn't you set this up as a list and use the employer table as the lookup field?


Thanks for the advice. I had already figured this one out a few days ago and forgot to mark it solved.
Mike