This topic is locked

Master-Detail

2/10/2009 10:38:06 AM
PHPRunner General questions
I
imendes author

Hi,
I have 4 tables:

  • LICENSES (LIC_ID, LIC_SOFTWARE, LIC_COMPANY)
  • SOFTWARE(SOFT_ID, SOFT_NAME)
  • COMPANIES (COMP_ID, COMP_NAME)
  • COMP_CONTACTS(CONT_ID, CONT_NAME, CONT_COMPANY)
    For the LICENSES_list I made the relationships between the first three tables. Everyting works fine.

    My problem is that I want to make a link in that form (LICENSES_list) to show the contacts for the COMPANY field is each row. The problem is that the COMP_CONTACTS is not a detail table of LICENSES. It's a detail table for COMPANIES.

    I managed to show that information, but is hardcoded, because I don't know how to obtain the value of the LIC_COMPANY. In this case it always shows the contacts for CONT_COMPANY=1: (licenses_list.html)
    <td valign=middle align=middle class=tablelinks2>

    <a href="comp_contacts_list.php?mastertable=companies&masterkey1=1"

    {if $useAJAX}

    onmouseover="RollDetailsLink.showPopup(this,'comp_contacts_detailspreview.php?mastertable=companies&masterkey1=1');" onmouseout="RollDetailsLink.hidePopup();" {/if}>Contacts</a>

    </td>
    How can I obtain the value of the LIC_COMPANY field? I tried to use the {$LIC_ENTIDADE_value} tag, but it shows the company name, not the company ID, because it's a lookup field.
    Thank you

J
Jane 2/13/2009

Hi,
you can do the following:

  1. create view in the database and join COMPANIES and COMP_CONTACTS tables in this view,
  2. use thise view as detail table for LICENSES table.