This topic is locked

Lookup Wizard & Drop Down Selection Box

11/20/2005 7:41:40 PM
PHPRunner General questions
N
nzmark author

Can anyone help ?
I have 2 tables Organisations and Contacts.
When entering a record in the contacts database I link to the Organisations table using a field "organisation_code" which is set to the key field code from the orgainisations table.
What I am having problems with is this....
I would like to have a field called "main_contact" in my organisations table that is selected from the contcats table. Using the lookup wizard I have managed to get a drop down listing displaying ALL contacts from the contacts databse.
I would like to restrict the lookup list to only those contacts that were added and associated with the currently selected organisation.
I ihave tried using a WHERE clause like WHERE contacts.organisation_code = organisations.code in various forms but just keep getting errors.
If I manually set the code such as WHERE "organisation_code like '2346'" it works fine.
Apologies if this is all as-clear-as-mud but am new to this.
Cheers
Mark

admin 11/21/2005

Mark,
you can do this by using Lookup WHERE Option in PHPRunner and applying some modifications to generated pages.

  1. Open Formatting tab in PHPRunner, click Edit format for main_contact field.

    Enter the following into WHERE box:
    "contacts.organisation_code = '".@$_SESSION["orgcode"]."'"



2. Build the pages

3. Open organisations_edit.php file with a text editor.

Locate this line inside it:

$data=db_fetch_array($rs);



and insert this just after:

$_SESSION["orgcode"]=$data["code"];