Skip to main content
Inspiring
August 16, 2008
Question

Looking up a field's entries from another table

  • August 16, 2008
  • 1 reply
  • 266 views
Not sure if I've best summarised that, but here's what I'm looking to do.

Basically, at the moment I have two tables :

Employers
Contacts

But the eventual idea is for it to be a one-to-many set up, so any given employer can have many contacts.

I've gotten as far as creating the two tables, and all the pages to add / display / update / delete and search each of these.

The way it should work, is that a main record should always be created first in the Employers table.

But what I'd like to do is have a a drop down list on the 'Add Contact' form, which displays each existing 'Employer Name' from the Employers table, which acts to link that Contact to the existing Employer.

I presume this should be possible, but I'm not sure exactly how to go about it.

Any pointers much appreciated.
This topic has been closed for replies.

1 reply

Inspiring
August 17, 2008
This is entirely possible. The Employers table presumably has both an
EmployerID (PK) and a Name field. The Contacts table should have an
EmployerID (FK) field so that you can establish a 1:M relationship.

On the Add Contacts form, you populate the text portion of the Employer
drop-down from the Employers.Name field, but set the value to the
Employers.ID field.

For ASP.NET, this can be done visually by creating a DropDownList, pointing
it to a DataSource, and selecting the display and value fields in the GUI.

For PHP, have a look at
http://forums.devarticles.com/mysql-development-50/drop-down-menu-populated-from-a-mysql-database-1811.html

HTH

Steve

"Iain71" <webforumsuser@macromedia.com> wrote in message
news:g863c6$iq3$1@forums.macromedia.com...
> Not sure if I've best summarised that, but here's what I'm looking to do.
>
> Basically, at the moment I have two tables :
>
> Employers
> Contacts
>
> But the eventual idea is for it to be a one-to-many set up, so any given
> employer can have many contacts.
>
> I've gotten as far as creating the two tables, and all the pages to add /
> display / update / delete and search each of these.
>
> The way it should work, is that a main record should always be created
> first
> in the Employers table.
>
> But what I'd like to do is have a a drop down list on the 'Add Contact'
> form,
> which displays each existing 'Employer Name' from the Employers table,
> which
> acts to link that Contact to the existing Employer.
>
> I presume this should be possible, but I'm not sure exactly how to go
> about it.
>
> Any pointers much appreciated.
>