SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2004
    Location
    usa
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    pHP/MySQL Pulling PK to use as FK

    I am working on a DB that will contain 3 tables

    1. patients
    2. house_members
    3. documents

    Tables 2 and 3 will have a FK from table 1

    I have an initial form which inputs data into table 1. After data is entered into table it is displayed on the screen along with a secondary form. The information in this form is to be input into table 2. Upon submitting this form, the info is displyed again with another form to upload files into table 3.

    The 2nd and 3rd forms are dynamic and depend on the info from the previous form.

    My question is... How do I pull the correct PK from table 1 so that it can be entered as the FK in tables 2 and 3?

    Its not too much of a problem if only one person is entering applications, but what if more than one are submitting to the db?

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You should be able to obtain it using mysql_insert_id.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Member
    Join Date
    Jun 2004
    Location
    usa
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'll try it out later tonight.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •