Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Looking up a field's entries from another table

Enthusiast ,
Aug 16, 2008 Aug 16, 2008
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.
TOPICS
Server side applications
224
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 17, 2008 Aug 17, 2008
LATEST
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-18...

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.
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines